TA的每日心情 | 开心 昨天 06:36 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
管理员
- 积分
- 1308
|
- #include "StdAfx.h"
- #include "StdArx.h"
- #include <dbpl.h>
- #include "..\..\Common\Others\ConvertUtil.h"
- #include "..\..\Common\Document\DwgDatabaseUtil.h"
- #include <dbents.h>
- #include <dbregion.h>
- #include "..\..\Common\Entity\RegionUtil.h"
- // This is command 'INTERSECT1'
- void ZffMyProjectintersect1()
- {
- // TODO: Implement the command
- ads采用name polyLinename;
- ads采用name polyLinename2;
- ads采用point pnt;
- ads采用point pnt2;
- AcDbPolyline *pPolyline=NULL;
- AcDbPolyline *pPoly=NULL;
- AcDbRegion *pRegion1=NULL;
- AcDbRegion *pRegion2=NULL;
- acedEntSel("\n请选择截取多段线!",polyLinename,pnt);
- AcDbObjectId polyLineId;
- acdbGetObjectId(polyLineId,polyLinename);
- AcDbEntity *pEnt=NULL;
- AcGePoint3dArray pts,pts2;
- acdbOpenObject(pEnt,polyLineId,AcDb::kForWrite);
- if (pEnt->isKindOf(AcDbPolyline::desc()))
- {
- pPolyline=AcDbPolyline::cast(pEnt);
- pEnt->close();
- }
- AcDbVoidPtrArray curves;
- int num=pPolyline->numVerts();
- for (int i=0;i<num;i++)
- {
- AcGePoint2d pt;
- pPolyline->getPointAt(i,pt);
- pts.append(CConvertUtil::ToPoint3d(pt));
- }
- pPolyline->getSplitCurves(pts,curves);
- pPolyline->close();
- AcDbObjectIdArray curvesId;
- AcDbCurve *pCurve=NULL;
- for (i=0;i<curves.length();i++)
- {
- pCurve=static采用cast<AcDbCurve*>(curves[i]);
- curvesId.append(CDwgDatabaseUtil::PostToModelSpace(pCurve));
- }
- pCurve->close();
- acedEntSel("\n请选择被截取多段线!",polyLinename2,pnt2);
- acdbGetObjectId(polyLineId,polyLinename2);
- acdbOpenObject(pEnt,polyLineId,AcDb::kForWrite);
- if (pEnt->isKindOf(AcDbPolyline::desc()))
- {
- pPoly=AcDbPolyline::cast(pEnt);
- pEnt->close();
- //pPoly->intersectWith(pPolyline,AcDb::kOnBothOperands,pts,0,0);
- }
- AcDbVoidPtrArray curves2;
- num=pPoly->numVerts();
- for (i=0;i<num;i++)
- {
- AcGePoint2d pt2;
- pPoly->getPointAt(i,pt2);
- pts2.append(CConvertUtil::ToPoint3d(pt2));
- }
- pPoly->getSplitCurves(pts2,curves2);
- pPoly->close();
- AcDbObjectIdArray curvesId2;
- AcDbCurve *pCurve2=NULL;
- for (i=0;i<curves2.length();i++)
- {
- pCurve2=static采用cast<AcDbCurve*>(curves2[i]);
- curvesId2.append(CDwgDatabaseUtil::PostToModelSpace(pCurve2));
- }
- pCurve2->close();
- AcDbObjectIdArray regId=CRegionUtil::Add(curvesId);
- AcDbObjectIdArray regId2=CRegionUtil::Add(curvesId2);
- for (i=0;i<curvesId.length();i++)
- {
- acdbOpenObject(pCurve,curvesId[i],AcDb::kForWrite);
- pCurve->erase();
- pCurve->close();
- }
- for (i=0;i<curvesId2.length();i++)
- {
- acdbOpenObject(pCurve2,curvesId2[i],AcDb::kForWrite);
- pCurve2->erase();
- pCurve2->close();
- }
- acdbOpenObject(pRegion1,regId[0],AcDb::kForWrite);
- acdbOpenObject(pRegion2,regId2[0],AcDb::kForWrite);
- pRegion1->booleanOper(AcDb::kBoolIntersect,pRegion2);
- pRegion1->close();
- pRegion2->close();
- }
复制代码 |
|