标注文字处于标注块中
ads_point pt;
ads_name ent;
if (RTNORM != acedEntSel(_T("\n选择一个标注"),ent,pt))
{
return;
}
AcDbObjectId objId;
acdbGetObjectId(objId,ent);
AcDbObjectPointer<AcDbDimension> pDim(objId,AcDb::kForRead);
Acad::ErrorStatus es=pDim.openStatus();
if (Acad::eOk != es)
{
acutPrintf(_T("\n错误码= %s"),acadErrorStatusText(es));
return;
}
AcDbObjectId blkdefId=pDim->dimBlockId();
AcDbBlockTableRecordPointer pBlkRcd(blkdefId,AcDb::kForRead);
es=pBlkRcd.openStatus();
if (Acad::eOk != es)
{
acutPrintf(_T("\n错误码= %s"),acadErrorStatusText(es));
return;
}
AcDbBlockTableRecordIterator *pIter=NULL;
es = pBlkRcd->newIterator(pIter);
if (Acad::eOk != es || pIter==NULL)
{
acutPrintf(_T("\n错误码= %s"),acadErrorStatusText(es));
return;
}
AcDbExtents ext;
bool bIsFind=false;
for (pIter->start();!pIter->done();pIter->step())
{
AcDbObjectId entId;
pIter->getEntityId(entId);
AcDbEntityPointer pEnt(entId,AcDb::kForRead);
if (pEnt->isKindOf(AcDbMText::desc()))
{
es= pEnt->getGeomExtents(ext);
if (Acad::eOk == es)
{
bIsFind=true;
}
}
}
if (bIsFind)
{
AcGePoint3d ptMin=ext.minPoint();
AcGePoint3d ptMax=ext.maxPoint();
acedCommand(RTSTR,_T("._RECTANG"),RTSTR,_T("_non"),RT3DPOINT,asDblArray(ptMin),RTSTR,_T("_non"),RT3DPOINT,asDblArray(ptMax),RTNONE);
acutPrintf(_T("\n包围盒((%0.4lf %0.4lf %0.4lf)(%0.4lf %0.4lf %0.4lf))"),ptMin.x,ptMin.y,ptMin.z,ptMax.x,ptMax.y,ptMax.z);
}