Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I used these methods above to check entities' intersection
AcDbEntity* selectEntity(const ACHAR* prompt, AcDbObjectId& id, AcGePoint3d& pick, AcDb::OpenMode openMode ) { AcDbEntity* ent = NULL; ads_name ename; if(acedEntSel(prompt, ename, asDblArray(pick) ) == RTNORM) { if(acdbGetObjectId(id,ename)==Acad::eOk) { if(acdbOpenAcDbEntity(ent,id,openMode)==Acad::eOk) return ent; } } return ent; } void Test() { // TODO: Implement the command AcDbEntity* pEnt1; AcDbEntity* pEnt2; AcGePoint3d pick; AcDbObjectId id; Acad::ErrorStatus es; AcGePoint3dArray is; if((pEnt1 = selectEntity(_T("\nSelect 1st entity : "), id,pick,AcDb::kForRead))== NULL) { acutPrintf(L"\nSelection failed"); return; } if((pEnt2 = selectEntity(_T("\nSelect 2nd entity : "), id,pick,AcDb::kForRead))== NULL) { acutPrintf(_T("\nSelection failed")); pEnt1->close(); return; } es = pEnt1->intersectWith(pEnt2,AcDb::kOnBothOperands,is); if(es != Acad::eOk) { acutPrintf(_T("\nIntersectWith failed : es = %s"), acadErrorStatusText(es)); } else { acutPrintf(_T("\nGot %d intersections"),is.length()); for(int i= 0;i<is.length();i++) { acutPrintf(_T("\nIntersection[%d] :(%.3lf,%.3lf,%3.lf)"), i,is[i].x,is[i].y,is[i].z); } } pEnt1->close(); pEnt2->close(); }
When I selection two entities with no intersection, it works well. However, when I take two entities with intersection, it crashes. It's apparently a issue from the intersectWith method., but I don't know why.
Solved! Go to Solution.