Author Topic: Setting Layer Problem & Handle->vla-object.  (Read 1943 times)

0 Members and 1 Guest are viewing this topic.

csgoh

  • Newt
  • Posts: 176
Setting Layer Problem & Handle->vla-object.
« on: July 12, 2006, 08:34:00 PM »
Question 1.
I wrote this function a to thaw,on and unlock.    However, whenever the layer is a current layer, it gives me an "Automation Error. Invalid layer". Any remedy to the problem is much appreciated.
Code: [Select]
;; ========================================================
;; wg:activate-layer
;; function to turn on, thaw and unlock if layers exist.
;;
(defun WG:activate-layer (lan1 objLayers / layer)
  (cond ((not (vl-catch-all-error-p (setq layer (vl-catch-all-apply 'vla-item (list objLayers lan1)))))
         (vla-put-Freeze layer ':vlax-false)
         (vla-put-Layeron layer ':vlax-true)
         (vla-put-Lock layer ':vlax-false)
         (princ (strcat "\nLayer " lan1 " on,thawed & unlocked ....")
         )
        )
  )
) ;_WG:activate-layer


Question 2.
How do one convert a handle to a vla-object?

Thanks.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Setting Layer Problem & Handle->vla-object.
« Reply #1 on: July 12, 2006, 09:48:38 PM »
1. You cannot use the Freeze property on the ActiveLayer, rather you can query it but you cannot set it....even if it's to false. So just add a check to see if lan1 is current before setting that property.

2. (vla-handletoobject (vla-get-activedocument (vlax-get-acad-object)) handle)