VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Expert Challenge-I need to link blocks together with a leader.

1 REPLY 1
Reply
Message 1 of 2
danranderson327
414 Views, 1 Reply

Expert Challenge-I need to link blocks together with a leader.

I will try to provide the best description as possible, an image is included:

 

I have multiple blocks laid out in a pattern, that can vary.  I need to draw a leader to connect them.  The number of blocks included in one leader is determined by the user.  In the example image, 12 is the number required.

 

Logic: Best to try and link block horizontally, with the minimum number of vertical connections, but the goal is not to have large gaps between blocks.

 

I am hoping for some direction, Thank you

1 REPLY 1
Message 2 of 2
aksaks
in reply to: danranderson327

I think your first step is to group all blocks that are directly adjacent to each other in either horizontal or vertical direction into groups. Call these groups "blobs".  In brute force this means comparing each block to all other blocks and then adding the passing blocks into the blob group and then performing the same process on that added block. You start a new blob group once you have exhausted all the trys. So I would start putting all "unblobbed" blocks into a collection. There might be some value to sorting by coordinates this ungrouped collection prior to starting the group creation process. That might streamline the comparison process. So in the blobbing process decribed above you are picking out of the unblobbed collection. This collection dimishes to nothing by the end of this intial blobbing process. The next step must be something like where you categorize the blobs by how far away they are from each other. You would use that information to decide which blobs to connect across if you need to. But I am not sure what the best approach would be. It might be that you treat all blob collections that have a count that is a multiple of the "leader connection number" separately since each of these can be leader connected with no gaps. That would leave all the odd blob collections to be treated by how far they are away from each other, but there is the chance that two odd blob collections sandwich a self contained blob collection where the gap distance might be less if all three were connected. So I'm stumped.

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

Post to forums  

Autodesk Design & Make Report

”Boost