Set transparency of all locked layers (essentially LAYISO/LAYUNISO for plotting)

Set transparency of all locked layers (essentially LAYISO/LAYUNISO for plotting)

Anonymous
Not applicable
1,856 Views
4 Replies
Message 1 of 5

Set transparency of all locked layers (essentially LAYISO/LAYUNISO for plotting)

Anonymous
Not applicable

Dear Experts,

 

Would it be possible to write a LISP routine that sets the layer transparency of all locked layers to a user-defined value (e.g., 70)?

 

As you all know, LAYISO can lock-and-fade all but the isolated layer(s) in modelspace/paperspace, but the locked-and-faded layers will still plot at the transparency level set in the Layers Property Manager.

 

My workflow would be LAYISO, then this LISP routine to set all other layers to transparency = 70, then PLOT, then this LISP routine to return all other layers to transparency = 0, then LAYUNISO.

 

Thoughts? Thank you all for your insight!

Accepted solutions (1)
1,857 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

Try this one.

 

(vl-load-com)

;-----
(defun c:LLTransparency (/ *error* cmd trs lst)  ; Layer Locked
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if cmd (setvar 'cmdecho cmd))
    (princ))
  
  (setq cmd (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  
  (if (and (setq trs (cond ((getint "\nTransparency <0>: "))
			   (0)))
	   (or (<= 0 trs 90)
	       (prompt "\nError: Allowed range 0-90."))
	   )
    (progn
      (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
	(if (= (vla-get-lock lay) :vlax-true)
	  (setq lst (cons (vla-get-name lay) lst))))
      
      (if lst
	(progn
	  (command "_.layer")
	  (foreach l lst
	    (command "_TRansparency" 70 l))
	  (command "")
	  (princ (strcat "\n" (itoa (length lst)) " layers changed a transparency to 70.")))
	(princ "\nNo locked layers found."))))
  
  (*error* "end")
  )
0 Likes
Message 3 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Minor fix.

 

(vl-load-com)

(defun c:LLTransparency (/ *error* cmd trs lst)  ; Layer Locked
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if cmd (setvar 'cmdecho cmd))
    (princ))
  
  (setq cmd (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  
  (if (and (setq trs (cond ((getint "\nTransparency <0>: "))
			   (0)))
	   (or (<= 0 trs 90)
	       (prompt "\nError: Allowed range 0-90."))
	   )
    (progn
      (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
	(if (= (vla-get-lock lay) :vlax-true)
	  (setq lst (cons (vla-get-name lay) lst))))
      
      (if lst
	(progn
	  (command "_.layer")
	  (foreach l lst
	    (command "_TRansparency" trs l))
	  (command "")
	  (princ (strcat "\n" (itoa (length lst)) " layers changed a transparency to " (itoa trs) ".")))
	(princ "\nNo locked layers found."))))
  
  (*error* "end")
  )
0 Likes
Message 4 of 5

Anonymous
Not applicable

Absolute perfection. Thank you so much, BeekeeCZ!

This script will come in handy for me on a daily basis.

 

Thank you for making my life *that* much easier.

0 Likes
Message 5 of 5

venturini.anthony
Advocate
Advocate

how would it be if i wanted to have a set list of layers to make transparent, not the locked layers. for example, the code would have layers 2,4,6,8 being able to change transparency, but layers 1,3,5,7,9 would not be effected by this. 

0 Likes