Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Grab an attribute then use it to turn off a layer

3 REPLIES 3
Reply
Message 1 of 4
brian_shick
221 Views, 3 Replies

Grab an attribute then use it to turn off a layer

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

3 REPLIES 3
Message 2 of 4
paullimapa
in reply to: brian_shick

Message 3 of 4
hmsilva
in reply to: brian_shick

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

EESignature

Message 4 of 4
_Tharwat
in reply to: brian_shick

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost