ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue Joining Polylines

1 REPLY 1
SOLVED
Reply
Message 1 of 2
jmaniaAZNPL
578 Views, 1 Reply

Issue Joining Polylines

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.

 

POST_2.pngPOST_1.png

Tags (2)
1 REPLY 1
Message 2 of 2
jmaniaAZNPL
in reply to: jmaniaAZNPL

I found the issue. It happens that my group of polylines sometimes have multiple of the same polyline. This causes join to fail.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost