PDA

View Full Version : Saving and Restoring Layer States



joel.shelstrom
2007-05-16, 05:19 PM
Hello Everyone,
I am in need of a Visual LISP function to save and restore layer states. We currently have a lisp function that automatically udpates the colors in the layers whenever the user saves their drawing. What i want is to do is to save the current layer state of the drawing, unlock all the layers, and then at the end of my function the layer state will be restored.

Any help on this would be greatly appreciated. I searched these forums, along with others, and have not been able to find anything on this.

Thanks,

rkmcswain
2007-05-16, 06:18 PM
What about this?



;; To save a layer state
(command "._layer" "_A" "_S" "myLayerState" "" "" "")
(graphscr)

;; Unlock all layers
(command "._layer" "_U" "*" "")

;; To restore a layer state
(command "._layer" "_A" "_R" "myLayerState" "" "")

joel.shelstrom
2007-05-16, 06:24 PM
Since i am using this function from within a reactor, AutoCAD commands will not work.

CADmium
2007-05-16, 06:59 PM
Have a look on


(setq LSTMAN(vla-GetInterfaceObject
(vlax-get-acad-object)
(strcat "AutoCAD.AcadLayerStateManager."
(substr(getvar "ACADVER") 1 2)
)
)
)
(vlax-dump-object LSTMAN 'T)
(vlax-release-object LSTMAN)



and use the methods of the AcadLayerStateManager-Object

joel.shelstrom
2007-05-16, 07:03 PM
Thanks Thomas,
I'll give that a try