shailujp Posted March 4, 2014 Share Posted March 4, 2014 Hello, I ran into a unique issue today with mass renamed blocks done by RENBLKS (a great lisp created by Tharwat) and existing old blocks and I spent few hours to replace old blocks with new ones using BLOCKREPLACE command. So, here is what happened. When I want to create a new version of the same concept, I copy blocks (which has a huge nested tree) in a new drawing, add prefix "modified_" using RENBLKS to rename all blocks, bring it back into original drawing, now I have two versions OLD & NEW. Somewhere, I mixed-up old blocks and new blocks and want to get rid old ones using BLOCKREPLACE express tool utility. My layout is huge around 90MB and takes about 3 to 4 minutes to replace one block at a time and about 15 to 20 blocks to replace. Also, to be able to use BLOCKREPLACE, I had to explode all nested blocks to be able to pick just the desired block. Here is my question, is there a lisp which can replace a complete list of blocks which has a same name as old but with "modified_" as prefix at once? ex. door1 modified_door1 door 2 modified_door2 Thanks Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 5, 2014 Author Share Posted March 5, 2014 Anyone wish to help me please? I have something similar coming up from next week. Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 11, 2014 Author Share Posted March 11, 2014 Since nobody replied to this, I'm trying this again hoping that someone might have answer to this. Is it possible to replace a list of old blocks with the same name new blocks but with prefix as "Modified_"? Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 11, 2014 Share Posted March 11, 2014 Please check the tool from this previous thread. Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 11, 2014 Author Share Posted March 11, 2014 MSasu, Thanks for your reply. Just looking at this code, it seems like it requires selection of old block and then the new block. This is where I need help of a whole list of blocks replaced with the new list. Is this possible? Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 19, 2014 Author Share Posted March 19, 2014 Does anyone have any idea on this? Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 20, 2014 Author Share Posted March 20, 2014 I hope someone sees this before I give up on this. Getting impatient but consider its only human. Quote Link to comment Share on other sites More sharing options...
steven-g Posted March 20, 2014 Share Posted March 20, 2014 Maybe posting an example of the old and the modified blocks showing the nesting, would give someone an idea about how to approach this. Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 20, 2014 Author Share Posted March 20, 2014 I will post the example tomorrow. In the mean time I have copied a snap from Lee Mac website to explain it better. There are 3 nested entities on this snap and have copied all of them with a new name with prefix "Modify_". Now when the design is finalized, not all new items go on the final version. So, if all my "modified nested 3" versions need to replace the "nested 3" I will have to explode all blocks to expose nested 3 & modified nested 3 to be able to pick & replace. And there are so many of this and my file size troubles me the most. Does this explanation work for now? Quote Link to comment Share on other sites More sharing options...
steven-g Posted March 20, 2014 Share Posted March 20, 2014 Without seeing the actual blocks, it's hard to give a definite answer but I just ran a simple test, I created a drawing with a nested block (3 levels) and made multiple copies of it. I then created a new drawing again with a nested block with the same names for the blocks but drawn completely differently, so the first drawing the blocks contained only squares, and in the second drawing they contained only circles. The second drawing only needs the one block this is the new style block (but keeps the old names). I then copied everything out of the first drawing into the second one, and all the blocks changed to the same style as the new block, you could then rename the blocks if you need too, and now use the new drawing which contains all the updated blocks. I can imagine there may be other issues to deal with, so an example of your drawing would help. But it works and only takes seconds to update all the blocks. Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 20, 2014 Share Posted March 20, 2014 I hope someone sees this before I give up on this. Getting impatient but consider its only human. Please don't miss that this isn't a develop-on-demand establishment! May want to adjust the parts in blue to suit your case; just make sure that all layers were un-locked. ;;; Replace Blocks By List (20-III-2014) (defun c:RBBL( / blockOld blockNew ssetBlocks entBlock assocBlock ) (foreach blockOld '("[color=blue]B1[/color]" "[color=blue]B2[/color]" "[color=blue]B3[/color]") ;;;list of blocks to replace (if (and (tblsearch "BLOCK" blockOld) (tblsearch "BLOCK" (setq blockNew (strcat "modified_" blockOld)))) (if (setq ssetBlocks (ssget "_X" (list '(0 . "INSERT") (cons 2 blockOld)))) (while (> (sslength ssetBlocks) 0) (entmod (subst (cons 2 blockNew) (assoc 2 (setq assocBlock (entget (setq entBlock (ssname ssetBlocks 0))))) assocBlock)) (ssdel entBlock ssetBlocks) ) ) ) ) (princ) ) By the way, this doen't consider the nested blocks. Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 21, 2014 Author Share Posted March 21, 2014 Hi MSasu Please don't miss that this isn't a develop-on-demand establishment! Just politely asking for help and I know that most people like you are willing to help. I tried your lisp and works well. But then there is this nested block issue is indeed the main culprit and thats the main reason for posting this thread. Could this be resolved? Here is how I have tested it. Before and after snaps. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 21, 2014 Share Posted March 21, 2014 Hi , A few explanations before firing up Vlisp You do want to replace a list of blocks with new list of new block names that have the same block name but with a prefix Modified_ word ? Then you have nested blocks within the old block ( to be replaced ) to re-include them within the new replaced block name Which is Modified_ ? If you can upload a sample drawing with one example before and after it would great . Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 21, 2014 Share Posted March 21, 2014 Please pay extreme attention that replacement of nested blocks may go very wrong if the order of block names in list isn't the appropriate one! Should start with lowest level blocks (that it, the deeper nested ones) and continue to the main level. Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 21, 2014 Author Share Posted March 21, 2014 Tharwat. I have attached 2 files Before and After. As an example. look for items in Red on the lower blocks (which is my target). Before.dwg After.dwg Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 21, 2014 Author Share Posted March 21, 2014 Please pay extreme attention that replacement of nested blocks may go very wrong if the order of block names in list isn't the appropriate one! Should start with lowest level blocks (that it, the deeper nested ones) and continue to the main level. I see what you are refering to...I think that I wont need to replace all the levels of blocks. It will be either the top level (which will cover all internals) or the bottom one which will be individual. The worst case is when I have to replace the bottom level ones which are difficult to access unless its exploded to brought to flat level. Edit: Currently I'm looking for a way to extract (or manually copy pase) block names from the drawing. I saw Jeffery Sanders BLKTREE.lsp but it wont let me copy any text from the dialogue box. Still exploring on this. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 21, 2014 Share Posted March 21, 2014 Why did you upload before and after and modified ? What do you mean by modified ? Are we talking about one nested block ? Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 21, 2014 Author Share Posted March 21, 2014 Why did you upload before and after and modified ?What do you mean by modified ? Are we talking about one nested block ? Modifed_ shown in red is actually my source block and I want to replace some blocks from it to my target lower block. So, I showed what before and after in separate files so that you can make out the difference. Did I confuse this way? Yes one big nested block with a huge tree in it. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 21, 2014 Share Posted March 21, 2014 You have so many blocks inside each other and that looks complicated , and it is not a matter of replacing one block with another with one nested block as I alluded to . sorry Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 21, 2014 Author Share Posted March 21, 2014 You have so many blocks inside each other and that looks complicated , and it is not a matter of replacing one block with another with one nested block as I alluded to . sorry Yes so many blocks but this isnt the full block. I had to create a smaller version of the one huge block to be able to share it here. You can imagine my master file that is about 90 to 100 MB and number of such huge blocks and their difference versions on it. No problem. Thanks for looking into this though. 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.