@ Tharwat,
The highlighted section is unnecessary, since you already have the Layer Object bound to symbol 'x':
Originally Posted by
tharwat
Code:
(setq lays (vla-get-layers
(vla-get-activedocument (vlax-get-acad-object))
)
)
(vlax-for x lays
(if (eq (vla-get-lock (setq l (vla-item lays (vla-get-name x))))
:vlax-false
)
(vla-put-lock l :vlax-true)
)
)
It could be better written as:
Code:
(setq lays (vla-get-layers
(vla-get-activedocument (vlax-get-acad-object))
)
)
(vlax-for x lays
(if (eq (vla-get-lock x) :vlax-false)
(vla-put-lock l :vlax-true)
)
)
However, I would be inclined to follow the route suggested by Renderman, but note that a Regen may be required to show the fade:
Code:
(defun c:test ( / _ApplyCollectionProperty acdoc )
(defun _ApplyCollectionProperty ( collection property value )
(vlax-for item collection
(vl-catch-all-apply 'vlax-put-property (list item property value))
)
)
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
(_ApplyCollectionProperty (vla-get-layers acdoc) 'lock :vlax-true)
(vla-regen acdoc acallviewports)
(princ)
)