Jump to content

[SHARE] SyncBlock - Synchronize specific layers across multiple blocks with precise alignment


Recommended Posts

Posted

Hi everyone,

I want to share a LISP tool I recently developed called SyncBlock.

If you work with architectural or MEP backgrounds, you probably deal with this nightmare constantly: You have a Master Block (A), and several child blocks (B, C, D) that were copied from A but have some layers deleted to show different details. When the Master Block updates, synchronizing those child blocks without ruining their specific layer visibility—and without them flying off to random coordinates because their base points are all set to (0,0,0)—is a huge pain.

To solve this, I wrote a script that does the following:

1. You select the Master Block.

2. You window-select the target blocks.

3. The script reads which layers are currently active in the target block, clears it, and pulls only those matching layers from the Master Block.

The Magic (Consensus Voting Algorithm):

The biggest challenge was alignment. Standard Bounding Box methods fail if you delete half a room or add a dimension in the child block. To fix this, the script uses a "Consensus Voting" approach. It gathers all valid geometry centers in both blocks, pairs them up, calculates the displacement vectors (dX, dY), and lets them "vote." The offset with the overwhelming majority wins. This ensures pixel-perfect alignment even if the child block is heavily trimmed!

GitHub Repository:

https://github.com/beastt1992/SyncBlock-AutoCAD

 

The code avoids copying Hatches to prevent associativity crashes, and it safely handles older AutoCAD versions (like 2014) by using pure English prompts to avoid ANSI/UTF-8 encoding issues.

I’d love for you guys to test it out on your messy real-world drawings! Any feedback, bug reports, or suggestions for improvement are highly appreciated.

Cheers!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...