TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: psutter14 on December 16, 2008, 03:04:27 PM
-
Can anybody help with my problem?
I have 1000's of block that I need to change.
Iam using a lisp routine "reptext.lsp" to change the values within my blocks, however I had checked the Constant setting to Yes on most block and now I can not change the value of my Attributes.
Can anybody write a lisp to change the attribute mode setting, it needs to change the constant setting to unconstant.
Thanks Paul
-
Try this:
(defun c:toggleconstant (/ ss idx ename att)
(and
(setq ss (ssget '((0 . "INSERT") (66 . 1))))
(setq idx -1)
(while (setq ename (ssname ss (setq idx (1+ idx))))
(foreach att (vlax-invoke
(vlax-ename->vla-object ename)
'getattributes
)
(if (= (vla-get-constant att) :vlax-true)
(vla-put-constant att :vlax-false)
)
)
)
)
(princ)
)
-
Don't think that will work Ron, see quote below.
; Constant (RO) = 0
Wouldn't you have to change the attribute within the block definition? I'm not sure, as I don't use constant attributes.
/guess.
Edit: It does work, but you don't get the desired results. I'll stick with the way I say above for now. ;-)
-
Don't think that will work Ron, see quote below.
; Constant (RO) = 0
Wouldn't you have to change the attribute within the block definition? I'm not sure, as I don't use constant attributes.
/guess.
DOH! That's what I get for cutting and pasting from another post :-D
-
If the attribute is still going to be the same for all blocks, then you can change the constant attribute's value within the block definition, and it will update all the rest.
If you want them to be different per insert, then you will have to change it from constant-true to constant-false within the block definition, plus re-insert all the blocks, and erase the old ones.
What are you looking to do exacly? How much experience do you have with writing code?
And Welcome to theSwamp Paul!
-
If you want them to be different per insert, then you will have to change it from constant-true to constant-false within the block definition, plus re-insert all the blocks, and erase the old ones.
Hmm. There might be something of interest in this recent thread! :)
http://www.theswamp.org/index.php?topic=26399.0
And Welcome to theSwamp Paul!
x 2 :)
-
Ok...this one works: (makes all attributes in all blocks not constant...)
(defun c:attsnotconstant (/ b n)
(vl-load-com)
(while (setq b (tblnext "block" (not b)))
(setq n (cdr (assoc 2 b)))
(vlax-for o (vla-item (vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
n
)
(if (= (vla-get-objectname o) "AcDbAttributeDefinition")
(vla-put-constant o :vlax-false)
)
)
(command "attsync" "name" n)
)
)
(c:attsnotconstant)
-
Thanks ronjonp for the fast response, but Iam have a problem. When I open a file the routine start on its own, info from the command line are as follows:
error collecting attribute data
attsync complete
attsync; error; exception occurred : 0xC0000005 (Access Voilation)
Then a dialog box with:
fatal error: commands may not be nested more than 4 deep
I'll attached a file of some blocks for you to look at.
1000 thanks for trying
-
Paul,
Rons code works fine for me in AC2008 on the drawing you posted.
-
Time for the obvious questions ..
What version of Autocad are you using ?
I notice that the file was
Saved in an Acad 2000 format,
Created : Saturday, 2 January 1982 10:00:00
and has a Total editing time of 274 hours
??
-
Worked here as well.....
I added (vl-load-com) to the code above. Maybe that had something to do with it :?
-
Thanks ronjonp and all, this is the best site I have found yet. It does work :lol: I was using 2002. I have a demo version of 2007 and loaded it and it work great, except when I open the file it starts automatically.
You said you add (vl-load-com) will that make it start when I need it. If so where do I put it in the code.
And thanks again
thank you
thank you
thank you :lol: :lol: :lol: :-D :-D
-
(vl-load-com) loads the need Visual Lisp commands for the routine to work. Do a search around here for adding a lisp to start up..there a numerous examples.
And..you're welcome :)
-
Ron to the rescue again! :-D
-
Thanks ronjonp and all, this is the best site I have found yet. It does work :lol: I was using 2002. I have a demo version of 2007 and loaded it and it work great, except when I open the file it starts automatically.
You said you add (vl-load-com) will that make it start when I need it. If so where do I put it in the code.
And thanks again
thank you
thank you
thank you :lol: :lol: :lol: :-D :-D
(vl-load-com) doesn't have anything to do with when the lisp starts. If you erase the last line (c:attsnotconstant) then the program will be set up to run whenever you type in attsnotconstant in the command line. You can also shorten up that name to make it easier on yourself if you're going to do that...
-
Hello, I found this old thread with code almost good for me. Could anyone be so kind and add some line to change just 1 attribute specified by its tag? Thx