admin 发表于 2024-3-14 21:02:15

[每日一码] 使用ARX读取尺寸的文本内容

AcDbEntity *pEnt;
AcDbObjectId id;
AcGePoint3d ptPick;
ads采用name eName;
if (acedEntSel (采用T("Select a dimension: ") , eName, asDblArray (ptPick)) != RTNORM )
   return;
acdbGetObjectId (id, eName);
acdbOpenAcDbEntity (pEnt, id, AcDb::kForRead);
//----- Get the id of the block table record which owns the text entity
AcDbDimension *pDim =AcDbDimension::cast (pEnt);
if (pDim == NULL)
{
   pEnt->close ();
   return;
}
id =pDim->dimBlockId ();
pDim->close ();
AcDbBlockTableRecord *pr;
acdbOpenAcDbObject ((AcDbObject *&) pr, id, AcDb::kForRead);
//----- Iterating the block table record
AcDbBlockTableRecordIterator *pi;
pr->newIterator (pi);
while (!pi->done ())
{
   pi->getEntity (pEnt, AcDb::kForRead);
   if (pEnt->isKindOf (AcDbMText::desc ()))
   {
    AcDbMText *pt = (AcDbMText *) pEnt;
    ACHAR *s = pt->contents ();
    acutPrintf (s);
    delete s;
   }
   pEnt->close();
   pi->step();
}
pr->close();
页: [1]
查看完整版本: [每日一码] 使用ARX读取尺寸的文本内容