|
/*
函数名称:AppendEntity()
创建日期:20160922 LukyRen
功能描述:获取空间模型实体ID
参数描述:pEnt :实体
返回类型:实体Id
*/
AcDbObjectId McAcad:: AppendEntity(AcDbEntity *pEnt)
{
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
AcDbBlockTable *pBt;
pDb->getBlockTable(pBt, AcDb::kForRead);
AcDbBlockTableRecord *pBtr;
pBt->getAt(ACDB_MODEL_SPACE, pBtr, AcDb::kForWrite);
AcDbObjectId entId;
pBtr->appendAcDbEntity(entId, pEnt);
pBtr->close();
pBt->close();
pEnt->close();
return entId;
}
/*
函数名称: PtToStr
创建 人: LuckyRen
创建日期: 2010.08.01
功能描述: 将三维的点转化为字符串
返回类型: 字符串
参数意义: pt:要转化的三维点
修改记录: */
CString McAcad::PtToStr(const AcGePoint3d& pt)
{
CString sT;
sT.Format(_T("%lf,%lf,%lf"),pt.x,pt.y,pt.z);
return sT;
}
/*
函数名称: ExplodeEntity()
创建日期:20160922 LuckyRen
功能描述:炸开组装图实体
参数描述:无
*/
void McAcad::ExplodeEntity()
{
ads_name en;
ads_point pt;
if(acedEntSel(_T("\n选择所要炸开的实体:"),en,pt) != RTNORM)
{
return;
}
AcDbObjectId entId;
Acad::ErrorStatus es = acdbGetObjectId(entId,en);
if(es != Acad::eOk)
return;
AcDbEntity *pEnt = NULL;
acdbOpenAcDbEntity(pEnt,entId,AcDb::kForWrite);
AcDbVoidPtrArray pExps;
AcDbEntity *pExpEnt = NULL;
int count = 0;
if(pEnt->explode(pExps) == Acad::eOk)
{
count = pExps.length();//炸开实体后的个数
for(int i=0; i <pExps.length(); i ++)
{
pExpEnt = (AcDbEntity*)pExps[i];
acutPrintf(_T("\n分解后的实体对象类型是:%s"), pExpEnt->isA()->name());
if(AcDbLine::cast(pExpEnt) != NULL)
{//直线
AcDbLine* pLine = AcDbLine::cast(pExpEnt);
CString sT1,sT2;
AcGePoint3d P1;
AcGePoint3d P2;
P1 = pLine->startPoint();
P2 = pLine->endPoint();
sT1.Format(_T("\n 开始点:%s"),McAcad::PtToStr(P1));
sT2.Format(_T("\n 结束点:%s"),McAcad::PtToStr(P2));
acutPrintf(_T("\n %s%s%s"),sT1, sT2);
}
AppendEntity(pExpEnt);
}
pEnt->erase(true);
}
else
{
acutPrintf(_T("\n该实体对象不能被分解!"));
}
pEnt->close();
} |
|