-attedit

-attedit

Anonymous
Not applicable
794 Views
2 Replies
Message 1 of 3

-attedit

Anonymous
Not applicable

Need a lisp for attribute direct edit from the block or kindly make this one to run.

 

(defun c:atr( / )
  (setq newatt (strcase(getstring "\nEnter new atrribute value: ")))
  (setq att1 (entget (car (nentsel "\nSelect attribute: "))))
  (setq sset (ssget "x" (list (cons 2 blkname))))
  (princ)
)

 

 

0 Likes
Accepted solutions (1)
795 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this... hope I did understand.

 

Spoiler
; Change an attribute value within the block by selection an att

(vl-load-com)

(defun c:atr ( / atttag attvalue blkname em en ensel ss)
  
  (if (and (setq ensel (entsel "\nSelect attribute to change: "))
           (or (= (cdr (assoc 0 (entget (car ensel)))) "INSERT")
               (prompt "\nSelected entity is not a block."))
           (setq em (car (nentselp (cadr ensel))))
           (or (= (cdr (assoc 0 (entget em))) "ATTRIB")
               (prompt "\nSelected entity is not a attribute."))
           (setq en (car ensel))
           (setq blkname (assoc 2 (entget en)))
           (setq attvalue (cdr (assoc 1 (entget em))))
           (setq atttag (strcase (cdr (assoc 2 (entget em)))))
           (setq attvalue (lisped attvalue))
           (setq ss (ssget "_X" (list '(0 . "INSERT") blkname '(66 . 1))))
           )
    
;;;Posted by Jeff Mishler
;;;Discussion Groups - Visual LISP, AutoLISP and General Customization
;;;06-24-2004
    
    (vlax-for item (vla-get-activeselectionset
                     (vla-get-activedocument (vlax-get-acad-object)))
      (foreach att (vlax-safearray->list
                     (vlax-variant-value (vla-getattributes item)))
        (if (= atttag (strcase (vla-get-tagstring att)))
          (vla-put-textstring att attvalue)))))
  (princ)
)
Message 3 of 3

Anonymous
Not applicable

Perfect Boss!

0 Likes