Message 1 of 10
Problem find all intersection of Lines!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I am trying to create a simple code to find all the intersection points of the lines, but the code was unable to loop next second time, where did I go wrong:
I use 2 arrays: arrPts to hold intersections and arrPts0 to hold all intersections, no duplicate checks
This is my code:
ads_name sname;
int isok=acedSSGet(NULL, NULL, NULL, NULL, sname);
if (isok!= RNORM)
return;
Adesk::Int32 length=0; acedSSLength(sname, &length);
AcGePoint3dArray arrPts0;
for (int i = 0; i < length-1; i++) {
//get first entity from ssname -> adsname
AcDbObjectId id = AcDbObjectId::kNull; ads_name adse;
acedSSName(sname, i, adse);
//get entity from adsname -> AcDbObjectId -> ent
AcDbEntity* pEnt; openEntity(adse, id, pEnt, fR); // combine getobjectID+getentity
//loop extant selectionset -> get intersect -> add to array
for (int j=++i;j<length;j++)
{
AcDbObjectId id1 = AcDbObjectId::kNull; ads_name adse1;
acedSSName(sname, j, adse1);
AcDbEntity* pEnt1; openEntity(adse1, id1, pEnt1, fR);
//get intersect point
AcGePoint3dArray arrPts;
if (pEnt->intersectWith(pEnt1, AcDb::kOnBothOperands, arrPts) == Acad::eOk)
{
if (arrPts.length() != 0)
{
for (AcGePoint3d pt : arrPts)
arrPts0.append(pt); ///put all point to this array
}
pEnt1->close();
}
}
pEnt->close();
} //can't loop continueplease help me.
Thanks a lot!

