Message 1 of 19
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I wanted to add an attribute PRICE in all my blocks in a drawing but also wanted to check if that attribute already exists so that it can skip that task for that particular block. I tried to modify this code found on cadtutor forum but not working. Also if someone can make that added attribute invisible it would be better help for me.
defun c:add$ ( / ss i blk blks def AttObj)
(and
(setq ss (ssget '((0 . "INSERT"))))
(setq i (sslength ss))
(while (> i 0)
(setq blk (cdr (assoc 2 (entget (ssname ss (setq i (1- i)))))))
(if (not (vl-position blk blks))(setq blks (cons blk blks)))
)
)
(foreach blk blks
(setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk))
(if (/= "" (attributeTag-p (car (entsel)) "SHIPLOOSE"))
(prince)
)
(setq AttObj
(vla-addattribute def
8
acattributemodelockposition
"Enter Item #"
(vlax-3D-point 72 84)
"PRICE\U+0020"
"100"
)
)
(vlax-put AttObj 'Alignment acAlignmentmiddle) ;; 4
(command "_.attsync" "_N" blk)
)
(princ)
)
(vl-load-com) (princ)
Solved! Go to Solution.