Good morning,
I am very new to LISP and need your help, at this point I can only make minor changes to existing code but a lot of the code still is magic to me.
I have a block "ULTRA INFO" with an attribute "CIRCID" that can be used to help turn off a layer with that name that has "-DATA" added to the end. What I think we need to do is to grab the attribute variable and store it, then add a wild card * to the end, lastly have it turn off a layer with that name.
Here is my thought:
Some how scan the drawing for an attribute named "CIRCID" if it is found store it as "LAName"
Then turn off the layer: (command "-Layer" "off" "(LAName)*" "")
If an attribute named "CIRCID" doe not exist cancel and end the lisp.
Any help possible is greatly appreciated.
Thank you all in advance.
Brian
Doing a search for: ssget all blocks with attributes:
http://www.cadtutor.net/forum/showthread.php?55803-SSGET-attribute-value-in-a-block
Then the Layer Off command would be:
(command "-Layer" "off" (strcat LAName "*") "")
Area Object Link | Dwg Setup | Feet-Inch Calculator
Exchange App Store
One way...
(vl-load-com) (defun c:demo ( / ACTLAY LANAME SS) (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "ULTRA INFO") (66 . 1) ))) (foreach att (vlax-invoke (vlax-ename->vla-object (ssname ss 0)) 'getattributes) (if (= (strcase (vla-get-tagstring att)) "CIRCID") (progn (setq LAName (vla-get-textstring att) *adoc* (vla-get-ActiveDocument (vlax-get-acad-object)) actlay (vla-get-ActiveLayer *adoc*)) (vlax-for lay (vla-get-Layers *adoc*) (if (and (wcmatch (strcase (vla-get-name lay)) (strcase (strcat LAName "*"))) (not (= (strcase (vla-get-name lay)) (strcase LAName ))) ) (vla-put-LayerOn lay :vlax-false) ) ) ) ) ) ) (princ) )
HTH
Henrique