#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 choose to intercept polylines!", POLYLINENAME,PNT);
Acdbobjectid Polylineid;
Acdbgetobjectid (polylineid,polylinename);
Acdbentity *pent=null;
Acgepoint3darray pts,pts2;
Acdbopenobject (Pent,polylineid,acdb::kforwrite);
if (pent->iskindof (acdbpolyline::d ESC ()))
{
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::P osttomodelspace (Pcurve));
}
Pcurve->close ();
Acedentsel ("\ n Please select the intercepted polyline!", Polylinename2,pnt2);
Acdbgetobjectid (polylineid,polylinename2);
Acdbopenobject (Pent,polylineid,acdb::kforwrite);
if (Pent->iskindof (acdbpolyline::d ESC ()))
{
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::P osttomodelspace (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 ();
}
Multi-segment dynamic cutting closure area