- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm new to AutoLISP. I've gone through many tutorials most of which just show you math and how to loop. There are only a handful of tutorials that deal with acutal block manipulation which is where I struggle.
I've seen some of the great LISP functions that Lee Mac and Nate Holt (and others) have created and shared, but I have yet to find a routine that does the following:
(1) Find the block where BLOCK NAME = "VIFCD_001" AND ATTRIBUTE [TAG1] = "-M161"
(2) Inside that same block change the ATTRIBUTE [DESC] = "NEW PART NUMBER"
I would prefer that "BLOCK NAME" "TAG NAME" and "DESC NAME" be arguments in a function.
I've been trying to work from this routine (below), that will change attributes of a block. The only LISP routine I know prompts the user to select the block, however, I cannot prompt the user for anything - I need the block name to be passed as an argument
How do I use LISP to select the block where BLOCK NAME = "VIFCD_001" and its attribute TAG1="-M161"
THE CALL
(setq ent (car (entsel))) ;Prompts the user to select a block (changeVars "DESC" "NEW PART NUMBER" ent)
THE FUNCTION
(defun changeVars (tag newvalue ent / alist) (if (and (= (type ent) (read "VLA-OBJECT")) newvalue) (progn (setq alist ( vlax-invoke ent 'GetAttributes)) (foreach a alist) (if (= (vla-get-tagstring a) tag) (vlax-put-property a 'TextString newvalue) );endif );end foreach );end progn (if (= 'ename (type ent)) (reptag tag newvalue (vlax-ename->vla-object ent)) );endif );endif (princ) );end defun
Solved! Go to Solution.