获取标注文字包围盒简单实例

作者: admin 分类: C++,CAD,ObjectARX 发布时间: 2022-04-19 19:51

https://www.programminghunter.com/article/86882291508/

标注文字处于标注块中

		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);
		}

f4d86234a1a91a621bfc32948219af53.png

发表评论

您的电子邮箱地址不会被公开。

标签云