itacad Posted April 23 Posted April 23 Hi, in a drawing the attributes of a block (always the same block used many times) have been compiled incorrectly, that is, the content is correct, but the attribute to use was wrong. Is it possible to transfer the content from the "X" attribute to the "Y" attribute of all the "Z" blocks used? I would not like to proceed with redefining the block attributes and similar solutions (which in any case I cannot think of at the moment). Thanks in advance Quote
BIGAL Posted April 24 Posted April 24 (edited) You should know by now that you can look at a block and get attributes either using a TAG name or attribute order so take att3 delete it and put value in att7. Just start with. (setq obj (vlax-ename->vla-object (car (entsel "\nPick block object ")))) (setq atts (vlax-invoke obj 'Getattributes)) You can then loop through the atts checking tag name or if you iknow its postion uset (nth x atts) and change value. I did something previously about change attribute order it pops a dcl with tagname and order so change order number and block is rearranged. Not what I was looking for but close add the nentsel for pick other attribute and get textstring. Just look at code for getting ans. ; modify all blocks 1 attribute ; By AlanH March 2021 (defun c:attmod ( / x bname ans att ent ent2) (vl-load-com) (setq ans (getstring "\nEnter new string ")) (setq ent (nentsel "\nPick block attribute Enter to exit")) (setq tagname (cdr (assoc 2 (entget (car ent))))) (setq pt (car (cdr ent))) (setq pt (list (car pt)(cadr pt))) (setq ent2 (ssname (ssget pt) 0)) (setq bname (cdr (assoc 2 (entget ent2)))) (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 bname)))) (repeat (setq x (sslength ss)) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS (setq x (- x 1)) )) 'getattributes) (if (= tagname (strcase (vla-get-tagstring att))) (vla-put-textstring att ans) ) ) ) (princ) ) (c:attmod) Edited April 24 by BIGAL Quote
SLW210 Posted April 24 Posted April 24 I have moved your thread to the AutoLISP, Visual LISP & DCL Forum. 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.