PeterPan9720 Posted October 22, 2010 Posted October 22, 2010 Hi to everybody, Is there a way to modify the tools blocks replace available in Autocad Express Tools ?. I try to explain better : - The express tools blocks replaces "all" blocks inside the dwg comparing the name. - I would like to change only selected ones ? Is there a way to have access to express tools blocks replace "macro" and starting from that create another only for replace the selected one ?. Somebody think that could be easier create complete new tools for my issue ? Many thanks for all your support Quote
Lt Dan's legs Posted October 22, 2010 Posted October 22, 2010 Like match properties but matching blocks? Quote
PeterPan9720 Posted October 22, 2010 Author Posted October 22, 2010 Like match properties but matching blocks? I did not understood well your answer, but the original function matches the old blocks attributes with the new also. My mod would be works in the same way. Thanks Quote
ReMark Posted October 22, 2010 Posted October 22, 2010 If I understand you correctly you have, for example, 12 instance of block "ABC" in your drawing. Of these 12 you may only want to change 6 of them not all of them. Is that right? Quote
Lt Dan's legs Posted October 22, 2010 Posted October 22, 2010 ???? (defun c:mb (/ *error* ent ss ssent id) (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (setvar 'nomutt 0) (princ) ) (while (not (and (setq ent (car (entsel "\nSelect source block: "))) (eq "INSERT" (cdr (assoc 0 (setq ent (entget ent))))) ) ) (prompt "\nPlease select a block!!") ) (redraw (cdr (car ent)) 3) (prompt "\nSelect blocks to replace: ") (setvar 'nomutt 1) (repeat (setq id (sslength (setq ss (ssget '((0 . "insert")))))) (setq ssent (entget (ssname ss (setq id (1- id))))) (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent)) ) (setvar 'nomutt 0) (redraw (cdr (car ent)) 4) (princ) ) Quote
PeterPan9720 Posted October 22, 2010 Author Posted October 22, 2010 Yes, correct. Selecting that on screen, even if are in different layers. Thanks Quote
PeterPan9720 Posted October 22, 2010 Author Posted October 22, 2010 If I understand you correctly you have, for example, 12 instance of block "ABC" in your drawing. Of these 12 you may only want to change 6 of them not all of them. Is that right? Yes, correct. Selecting that on screen, even if are in different layers. Thanks Quote
PeterPan9720 Posted October 22, 2010 Author Posted October 22, 2010 ???? (defun c:mb (/ *error* ent ss ssent id) (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (setvar 'nomutt 0) (princ) ) (while (not (and (setq ent (car (entsel "\nSelect source block: "))) (eq "INSERT" (cdr (assoc 0 (setq ent (entget ent))))) ) ) (prompt "\nPlease select a block!!") ) (redraw (cdr (car ent)) 3) (prompt "\nSelect blocks to replace: ") (setvar 'nomutt 1) (repeat (setq id (sslength (setq ss (ssget '((0 . "insert")))))) (setq ssent (entget (ssname ss (setq id (1- id))))) (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent)) ) (setvar 'nomutt 0) (redraw (cdr (car ent)) 4) (princ) ) Seems to work fine, I'll try to select more than one Many thanks Quote
Sweety Posted October 22, 2010 Posted October 22, 2010 ???? (defun c:mb (/ *error* ent ss ssent id) (entmod (subst (assoc 2 ([b][color="red"]entget[/color][/b] ent))(assoc 2 ssent) ssent)) You have forgotten to add entget function dear dan Best regards Quote
PeterPan9720 Posted October 22, 2010 Author Posted October 22, 2010 Seems that with your modification doesn't work ! Quote
CADapult Posted October 22, 2010 Posted October 22, 2010 WooHoo! I had logged in to ask about the very same issue. Lt. Dan's legs, you sir are awesome! With a couple of small tweaks this will do exactly what I need and save me several hours of fumbling around working out the code. Thank you for helping me to end my very bad week on a high note! Mike Quote
alanjt Posted October 22, 2010 Posted October 22, 2010 Watch out when replacing attributed blocks. Quote
Lt Dan's legs Posted October 22, 2010 Posted October 22, 2010 Watch out when replacing attributed blocks. this correct Alan? (defun c:mb (/ *error* ent ss ssent id) (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (setvar 'nomutt 0) (princ) ) (while (not (and (setq ent (car (entsel "\nSelect source block: "))) (eq "INSERT" (cdr (assoc 0 (setq ent (entget ent))))) ) ) (prompt "\nPlease select a block!!") ) (redraw (cdr (car ent)) 3) (prompt "\nSelect blocks to replace: ") (setvar 'nomutt 1) (repeat (setq id (sslength (setq ss (ssget '((0 . "insert")))))) (setq ssent (entget (ssname ss (setq id (1- id))))) (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent)) [b][color=red](entupd ssent) [/color][/b] ) (setvar 'nomutt 0) (redraw (cdr (car ent)) 4) (princ) ) Quote
alanjt Posted October 23, 2010 Posted October 23, 2010 Entupd works on the entity, not it's data. Try entupd (cdr (assoc -1 ssent. However, I'm talking about what will happen if you replace an attributed block. Try it, you will notice the attributes of the former block are still there. You will have to step through it (using entnext) and entdel each attribute. I use the following; the replacement will only take on the rotation and size of the selected block and the original is just deleted. http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block&p=359585&viewfull=1#post359585 BTW, nice work. You are really coming along with your coding. Quote
PeterPan9720 Posted October 23, 2010 Author Posted October 23, 2010 Thank you to everybody for the support, The last code seems to work fine only if the "destination" object to replace is a single object. If I select more than one object just the last selected object will be replaced. Pls Help Me. Quote
PeterPan9720 Posted October 23, 2010 Author Posted October 23, 2010 Entupd works on the entity, not it's data. Try entupd (cdr (assoc -1 ssent. However, I'm talking about what will happen if you replace an attributed block. Try it, you will notice the attributes of the former block are still there. You will have to step through it (using entnext) and entdel each attribute. I use the following; the replacement will only take on the rotation and size of the selected block and the original is just deleted. http://www.cadtutor.net/forum/showthread.php?48458-Replace-Selected-Block-Or-Blocks-With-Another-Block&p=359585&viewfull=1#post359585 BTW, nice work. You are really coming along with your coding. Thank you for your support but seems that your code do not transfer the attributes during the replacement, I need also to do this. The best would be a mix between the two lsp, yours for multiple selection and the last from Lt Dan for the attributes. Thank you ! Quote
PeterPan9720 Posted November 3, 2010 Author Posted November 3, 2010 this correct Alan? (defun c:mb (/ *error* ent ss ssent id) (defun *error* (msg) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")) ) (setvar 'nomutt 0) (princ) ) (while (not (and (setq ent (car (entsel "\nSelect source block: "))) (eq "INSERT" (cdr (assoc 0 (setq ent (entget ent))))) ) ) (prompt "\nPlease select a block!!") ) (redraw (cdr (car ent)) 3) (prompt "\nSelect blocks to replace: ") (setvar 'nomutt 1) (repeat (setq id (sslength (setq ss (ssget '((0 . "insert")))))) (setq ssent (entget (ssname ss (setq id (1- id))))) (entmod (subst (assoc 2 ent)(assoc 2 ssent) ssent)) [b][color=red](entupd ssent) [/color][/b] ) (setvar 'nomutt 0) (redraw (cdr (car ent)) 4) (princ) ) Thank you for your support, but seems that the above code substitutes only the block attribute and not the complete block with the source blocks attributes. Thank You Quote
alanjt Posted November 3, 2010 Posted November 3, 2010 http://www.cadtutor.net/forum/showthread.php?48397-Copy-all-attributes...&p=329507&viewfull=1#post329507 Quote
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.