I have a list of polylines that form a closing boundary. I want to merge all these polylines into one to create a single entity that represents the boundary. I am using AcDbJoinEntityPE to do so but sometimes it does not join all the lines and I know that they are all touching each other.
AcDbPolyline* joinPolylines( std::vector<AcDbPolyline*> segments ) { if( segments.size() < 1 ) { return NULL; } Acad::ErrorStatus errorStatus; AcDbPolyline* ret = new AcDbPolyline(); AcDbJoinEntityPE* joinPE = AcDbJoinEntityPE::cast(segments[0]->queryX(AcDbJoinEntityPE::desc())); AcArray<AcDbEntity*> entities; AcGeIntArray index; if( joinPE == NULL ) { acutPrintf( L"\nERROR: Could not create join class" ); return NULL; } ret = (AcDbPolyline*)segments[0]->clone(); for( int i = 1; i < segments.size(); i++ ) { entities.append( segments[i] ); } errorStatus = joinPE->joinEntities( ret, entities, index ); if( errorStatus != Acad::eOk ) { acutPrintf( L"\nError: Could not join segments %s", acadErrorStatusText( errorStatus ) ); return NULL; } return ret; }
Here are some screen shots that show the function working and failing in the same file. The brown lines are all the lines segments i am joining and the white line is what my function creates.
Solved! Go to Solution.
Solved by jmaniaAZNPL. Go to Solution.
I found the issue. It happens that my group of polylines sometimes have multiple of the same polyline. This causes join to fail.