Set layer transparency by object selection

Set layer transparency by object selection

Justin_P_Carr
Explorer Explorer
314 Views
4 Replies
Message 1 of 5

Set layer transparency by object selection

Justin_P_Carr
Explorer
Explorer

Afternoon,

 

Would a lisp expert out there be able to write me a routine whereby I can change the transparency level of a layer by selecting an object on that layer? I have never go round to learning list even though I've used AutoCAD since the 1990's! (If anyone can suggest a good book that teaches lisp I would appreciate that too.)

Thanks in advance

0 Likes
315 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

Try this tool, not specifically for transparency, but for a wider layer setting. You can select multiple objects.

Message 3 of 5

paullimapa
Mentor
Mentor

Afralisp website is an excellent starting point to learn


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 4 of 5

paullimapa
Mentor
Mentor

Try this setlyt.lsp:

; defun setlyt change layer tranparency to match with selected object
; OP:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-layer-transparency-by-object-selection/m-p/13177737#M475351
(defun c:setlyt (/ en lyr tra)
  (while (not en)
    (setq en(entsel"\nSelect Object: "))
  )
  (setq en (car en))
  (setq tra(getpropertyvalue en "Transparency"))
  (setq lyr(getpropertyvalue(getpropertyvalue en "LayerID")"Name"))
  (cond
    ((= tra -2)(princ"\nCurrent Object Transparency Setting is ByBlock."))
    ((= tra -1)(princ"\nCurrent Object Transparency Setting is ByLayer."))
    (t
     (setpropertyvalue(tblobjname "LAYER" lyr)"Transparency" tra)
     (princ(strcat"\nLayer Transparency Changed to Match Object as: " (itoa tra)))
    )
  ) ; cond
  (princ) ; clean exit
) ; defun

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 5

Sea-Haven
Mentor
Mentor

Have a look at Kindle has some books at very reasonable prices. 4 books by 

 

Togores, Reinaldo N.. Advanced Programming Techniques (AutoCAD expert's Visual LISP Book 4) (Kindle Location 4). . Kindle Edition.

 

Nice thing is can copy and paste code from book.