|
/==============炸开============
static void TESTzhakaicmd()
{
// Add your code for command ahlzlARX._test here
ads_name ent;
ads_point pt;
if (acedEntSel(_T("\n请选择对象:"), ent, pt) != RTNORM)
{
return;
}
AcDbObjectId entId;
acdbGetObjectId(entId, ent);
AcDbEntity *pEnt = NULL;
acdbOpenObject(pEnt, entId, AcDb::kForWrite);
AcDbVoidPtrArray pExps;
if (pEnt->explode(pExps) == Acad::eOk)
{
for (int i = 0; i < pExps.length(); i++)
{
AcDbEntity *pExpEnt = (AcDbEntity*)pExps[i];
acutPrintf(_T("\n分解后的对象类型名是: %s"), (pExpEnt->isA()->name()));
LoadEntity(pExpEnt);
}
pEnt->erase(true);
}
else
{
acutPrintf(_T("\n该对象不能被分解!"));
}
pEnt->close();
}
//选择两个对象,求交点;如果选了域,输出面积
static void TESTintersactcmd(){
ads_name ent1;
ads_point pt1;
if (acedEntSel(_T("\n请选择对象1:"), ent1, pt1) != RTNORM)
{
return;
}
AcDbObjectId entId1;
acdbGetObjectId(entId1, ent1);
AcDbEntity *pEnt1 = NULL;
acdbOpenObject(pEnt1, entId1, AcDb::kForWrite);
ads_name ent2;
ads_point pt2;
if (acedEntSel(_T("\n请选择对象2:"), ent2, pt2) != RTNORM)
{
return;
}
AcDbObjectId entId2;
acdbGetObjectId(entId2, ent2);
AcDbEntity *pEnt2 = NULL;
acdbOpenObject(pEnt2, entId2, AcDb::kForWrite);
AcGePoint3dArray ptArr;
pEnt1->intersectWith(pEnt2,AcDb::Intersect::kOnBothOperands,ptArr);
CString outStr;
outStr.Format(_T("交集点的数量:%d"),ptArr.length());
acutPrintf(outStr);
if(pEnt1->isKindOf(AcDbRegion::desc())){
AcDbRegion* r = (AcDbRegion*)pEnt1;
double area;
r->getArea(area);
CString str;
str.Format(_T("\n面积:%.2f"),area);
r->close();
}
pEnt1->close();
pEnt2->close();
}
外包矩形,返回外接矩形的两个端点
static void TESTgeocmd(){
ads_name ent;
ads_point pt;
if (acedEntSel(_T("\n请选择对象:"), ent, pt) != RTNORM)
{
return;
}
AcDbObjectId entId;
acdbGetObjectId(entId, ent);
AcDbEntity *pEnt = NULL;
acdbOpenObject(pEnt, entId, AcDb::kForWrite);
AcDbExtents extent;
Acad::ErrorStatus es = pEnt->getGeomExtents(extent);
if(es == Acad::ErrorStatus::eOk){
AcGePoint3d ptMin = extent.minPoint();
AcGePoint3d ptMax = extent.maxPoint();
CString str;
str.Format(_T("\nx1:%.2f ,y1:%.2f, z1:%.2f \nx2: %.2f,y2: %.2f, z2: %.2f"),ptMin[X],ptMin[Y],ptMin[Z],ptMax[X],ptMax[Y],ptMax[Z]);
acutPrintf(str);
}
}
|
|