callvey Posted March 24, 2014 Author Posted March 24, 2014 Yes it works now, thanks very much again. Quote
Tharwat Posted March 24, 2014 Posted March 24, 2014 Yes it works now, thanks very much again. Good stuff Quote
johmmeke Posted July 7, 2014 Posted July 7, 2014 (edited) first of all, sorry to respond on a old thread. I use the routine from Tharwat in #9 When i use this in acad 2014, all my attribute values are set back to default. Do i have a setting wrong? This has been working really fine in acad 2012. Greetz John Edited July 7, 2014 by johmmeke Quote
Tharwat Posted July 7, 2014 Posted July 7, 2014 I modified the routine in post #9 since that is the one you are using and added a few lines of codes to reset the same text strings of block's attributes that are in a drawing . try it and let me know . (defun c:Test (/ *error* cmd l a lst f h nm bks v cmd ss) ;; Tharwat 07. 07 . 2014 ;; (defun *error* (msg) (if cmd (setvar 'CMDECHO cmd) ) (if (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*") (princ msg) (princ (strcat "*** Error : " msg "***")) ) (princ) ) (or doc (setq doc (vla-get-activedocument (vlax-get-acad-object))) ) (setq cmd (getvar 'CMDECHO) l '(("AREA1" . "AREA13") ("AREA2" . "AREA14") ("AREA3" . "AREA15") ("AREA4" . "AREA16") ("AREA5" . "AREA17") ("AREA6" . "AREA18") ("AREA7" . "AREA19") ("AREA8" . "AREA20") ) ) (if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)))) ((lambda (i / sn f) (while (setq sn (ssname ss (setq i (1+ i)))) (foreach tg (vlax-invoke (vlax-ename->vla-object sn) 'GetAttributes ) (if (setq f (assoc (strcase (vla-get-tagstring tg)) l)) (setq lst (cons (list sn (cdr f) (vla-get-textstring tg)) lst) ) ) ) ) ) -1 ) ) (if lst (progn (vlax-for x (vla-get-blocks doc) (if (and (eq :vlax-false (vla-get-isxref x)) (eq :vlax-false (vla-get-islayout x)) ) (vlax-for o x (if (and (eq (vla-get-objectname o) "AcDbAttributeDefinition") (setq a (assoc (strcase (vla-get-tagstring o)) l)) ) (progn (vla-put-tagstring o (cdr a)) (if (not (member (setq nm (vla-get-name x)) bks)) (setq bks (cons nm bks)) ) ) ) ) ) ) (setvar 'CMDECHO 0) (mapcar '(lambda (n) (command "_.attsync" "_Name" n)) bks) (setvar 'CMDECHO cmd) (foreach x lst (foreach tg (vlax-invoke (setq v (vlax-ename->vla-object (car x))) 'GetAttributes ) (if (and (eq (strcase (vla-get-tagstring tg)) (strcase (cadr x))) (vlax-write-enabled-p v) ) (vla-put-textstring tg (caddr x)) ) ) ) ) ) (princ) ) (vl-load-com) Quote
johmmeke Posted July 7, 2014 Posted July 7, 2014 thank you works perfect again. This is a great help me, i often get drawing where the tag name's are not consistant. Thx again for the help, JOhn Quote
Tharwat Posted July 7, 2014 Posted July 7, 2014 thank you works perfect again. This is a great help me, i often get drawing where the tag name's are not consistant. Thx again for the help, JOhn Excellent . You're welcome John and I am really happy to help . Quote
johmmeke Posted July 8, 2014 Posted July 8, 2014 Tharwat, one thing i come across is that the routine is not working on dynamic block's. This is not so import to me, just to let u know. John Quote
Tharwat Posted July 8, 2014 Posted July 8, 2014 Tharwat, one thing i come across is that the routine is not working on dynamic block's. This is not so import to me, just to let u know. John That is correct , and I do know that John Simply due to the name of the dynamic block that can not be retrieved by the function vla-get-name which strongly supports my saying and would fail with Dynamic Blocks Quote
7o7 Posted July 8, 2014 Posted July 8, 2014 Tharwat, Although You can get the dynamic block by name, you can change it's tag name, but it doesn't effect its "child" dynamic blocks, because they are independent from their "parent". If you want to change tag name, you have to change every "child" block, not only their "parent". Try this: (defun c:test(/ l en tm) (setq l '(("AREA1" . "AREA13") ("AREA2" . "AREA14") ("AREA3" . "AREA15") ("AREA4" . "AREA16") ("AREA5" . "AREA17") ("AREA6" . "AREA18") ("AREA7" . "AREA19") ("AREA8" . "AREA20") ) ) (foreach en (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget "X" '((0 . "INSERT") (66 . 1)))))) (while (and (setq en (entnext en)) (/= (cdr (assoc 0 (entget en))) "SEQEND")) (if (and (= (cdr (assoc 0 (entget en))) "ATTRIB") (setq tm (assoc (cdr (assoc 2 (entget en))) l))) (entmod (subst (cons 2 (cdr tm)) (assoc 2 (entget en)) (entget en)))) ) ) (princ) ) Hope this can help. Quote
Tharwat Posted July 8, 2014 Posted July 8, 2014 @7o7 I wonder what 's new in your routine to mine ? Quote
7o7 Posted July 9, 2014 Posted July 9, 2014 The difference is you try to catch the block by name and to use the "attsync" command of cad, it change blocks to their default properties, such as color,.. My code is just surfing through each block, change only its tag name, and leave other properties unchanged. Quote
Tharwat Posted July 9, 2014 Posted July 9, 2014 The difference is you try to catch the block by name and to use the "attsync" command of cad, it change blocks to their default properties, such as color,..My code is just surfing through each block, change only its tag name, and leave other properties unchanged. Correct , and I know that I took the long way to reach the destination but it is okay since that we got what we want . But you may need to add a few codes to change the PARENT blocks' tag names as well as the CHILDREN 's did . Quote
NoamBrand Posted January 13, 2019 Posted January 13, 2019 Synchronizing attributes reverts the existing values to default This is a big problem with the lisp Quote
nikita2597 Posted September 21, 2020 Posted September 21, 2020 Nice script. is it also posible to rename the tagname without losing the already filled-value of the tag. 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.