Gotrekk Posted April 18, 2017 Share Posted April 18, 2017 Hi everyone, I have some different blocks with same attributes: "new_block" "block_num" ... some more attributes ... I'd like to select some of them and then replace them with another block named from value of "new_block" and "block_num". Do You think it's actually possible? For example, I have some blocks named "wallet" with attributes new_block = "paper" block_num = "13" id like to replace all selected blocks with a block called "paper_13", keeping all attributes, rotation, layer, scale, etc. I found this routine: http://www.cadtutor.net/forum/showthread.php?56790-Replace-only-selected-blocks-with-a-different-one&p=384911&viewfull=1#post384911 It does most of it, it replaces selected blocks with new one, but i have no idea on how to make it pick up the new block from current attributes. Any ideas? thanks in advance regards Quote Link to comment Share on other sites More sharing options...
David Bethel Posted April 18, 2017 Share Posted April 18, 2017 It can be very simple : Replacement BLOCK name "FDI-OLB" [b][color=BLACK]([/color][/b]defun c:blk-ch [b][color=FUCHSIA]([/color][/b]/ r ss i ed en[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq r [color=#2f4f4f]"FDI-OBL"[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"INSERT"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 2 [color=#2f4f4f]"FDI-OCT,FDI-OCT2"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq i 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmod [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 2 r[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 2 ed[b][color=BLUE])[/color][/b] ed[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entupd en[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq i [b][color=GREEN]([/color][/b]1+ i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Note the replacement block must exist in the current drawing for use to work. Beware, anytime you redefine an attributed block, unexpected results can happen in future drawings. All we are doing is referencing the replacement BLOCK geometry in lieu of the original's. I'm assuming that you can ( strcat ) together the replacement block name.. -David test.dwg Quote Link to comment Share on other sites More sharing options...
Gotrekk Posted April 19, 2017 Author Share Posted April 19, 2017 thank you a lot, i was able to complete it for my needs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.