eyeofnewt555 Posted March 8, 2017 Share Posted March 8, 2017 I've got a ton of blocks, each with the same attribute but different preset values. Obnoxiously, when they're inserted the dialogue box to edit the attribute value pops up (problem described here). I know this can be suppressed with ATTREQ, but I'd rather folks not have to change any settings and for this to work smoothly on its own. So, rather than manually going through and changing each attribute to preset > yes, anyone got a handy LISP for it? Thanks! Quote Link to comment Share on other sites More sharing options...
13lade001 Posted March 8, 2017 Share Posted March 8, 2017 You could turn off ATTREQ for them and reset it when your done or in the event of an error in your code. See Lee Mac's error handling page under the heading "Resetting the User Environment" that does this for the osm system variable. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 8, 2017 Share Posted March 8, 2017 Try the following: (defun c:presetattdefs nil (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-false (vla-get-islayout blk) (vla-get-isxref blk)) (vlax-for obj blk (if (and (= "AcDbAttributeDefinition" (vla-get-objectname obj)) (vlax-write-enabled-p obj)) (vla-put-preset obj :vlax-true) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
eyeofnewt555 Posted March 9, 2017 Author Share Posted March 9, 2017 You are a god among men. Thank you, Lee! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 9, 2017 Share Posted March 9, 2017 You're welcome, I'm glad it helps. Quote Link to comment Share on other sites More sharing options...
kevinpo Posted July 20, 2017 Share Posted July 20, 2017 Hello Lee, Is there a way of just changing one block (Tag-Revision) to a false preset? I am trying but keep getting tangled up in code. Thanks, Kevin Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 21, 2017 Share Posted July 21, 2017 Try this for one (setq obj (vlax-ename->vla-object (car (entsel "\nPick ")))) (if (and (= "AcDbAttributeDefinition" (vla-get-objectname obj)) (vlax-write-enabled-p obj)) (vla-put-preset obj :vlax-false) ) Quote Link to comment Share on other sites More sharing options...
kevinpo Posted July 21, 2017 Share Posted July 21, 2017 Thank you for the quick response but it didn't seem to change the Preset to No/false. I simply want to change the one attribute in the block definition to have the preset set to no. if I look at it in the properties palette in block editor it still says Yes for preset. I tried attsync after too and that still didn't change. I'd like to not have to select the block but rather just fix it if its in the drawing. Thank you!! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 21, 2017 Share Posted July 21, 2017 The following will change attributes with tag REVISION in all blocks: (defun c:presetattdefs nil (vlax-for blk (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) (if (= :vlax-false (vla-get-islayout blk) (vla-get-isxref blk)) (vlax-for obj blk (if (and (= "AcDbAttributeDefinition" (vla-get-objectname obj)) (vlax-write-enabled-p obj) [color=red](= "REVISION" (strcase (vla-get-tagstring obj)))[/color]) (vla-put-preset obj [color=red]:vlax-false[/color]) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted July 21, 2017 Share Posted July 21, 2017 BIGAL, Attribute Definitions are contained inside the Block's definition, while Attribute References are contained inside the Block's reference, hence: (defun C:test nil (vlax-map-collection (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-EffectiveName (vlax-ename->vla-object (car (entsel "\nSelect a block: ")))) ) (quote (lambda (o) (and (vlax-write-enabled-p o) (eq "AcDbAttributeDefinition" (vla-get-ObjectName o)) (vla-put-Preset o :vlax-false) ) ) ) ) ) I don't really know what that code should do, but it should work. Quote Link to comment Share on other sites More sharing options...
kevinpo Posted July 21, 2017 Share Posted July 21, 2017 Thanks Lee, For some reason I still cannot get the Preset to change. This didn't work. Is there a way I can just check to see if the preset is set to Yes in my block "Tag-Revision" so I can make a conditional workaround? Thanks Quote Link to comment Share on other sites More sharing options...
kevinpo Posted July 21, 2017 Share Posted July 21, 2017 Thanks GRR. This worked! Quote Link to comment Share on other sites More sharing options...
kevinpo Posted July 21, 2017 Share Posted July 21, 2017 Hello Grrr, Is there a way to get it to change the block giving the name and without having to pick? Quote Link to comment Share on other sites More sharing options...
kevinpo Posted July 21, 2017 Share Posted July 21, 2017 (edited) I got it, Thanks buys. (defun C:test nil (vlax-map-collection (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) "Tag-Revision") (quote (lambda (o) (and (vlax-write-enabled-p o) (eq "AcDbAttributeDefinition" (vla-get-ObjectName o)) (vla-put-Preset o :vlax-false) ) ) ) ) ) Edited July 24, 2017 by SLW210 Code Tags Quote Link to comment Share on other sites More sharing options...
Grrr Posted July 21, 2017 Share Posted July 21, 2017 I'm glad that it worked for you kevinpo, and that you figured out the solution for your problem by yourself! Lee's code works but your question misleaded to: attribute definition with a tag name of "Revision", although he was clear enough what his code does. I just tried to correct BIGAL, and to practice a bit. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 22, 2017 Share Posted July 22, 2017 No worries Grr always learning Quote Link to comment Share on other sites More sharing options...
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.