|
- //==============炸开============
- 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);
- }
- }
- 2
复制代码 |
|