View Full Version : Layer state to restore with script
I have tried to restore layer state in script, using command "-layer", but it doesn't restore properly some layers. These layers are frozen in VP Freeze. If I use Layerstate Restore from dialog It works fine, but I can't use dialog in script. Is there any way to fix this?
Thanks,
Stoyan
irneb
2009-08-10, 08:25 AM
Welcome to AUGI & congrats on your 1st post.
Unfortunately the command line version seems to not work with VPFreeze and / or VP Overrides. It simply Freezes the layer throughout the drawing, even while inside the relevant VPort.
Only way I can think of is to use some LISP, I know the guys in the AutoLisp forum (http://forums.augi.com/forumdisplay.php?f=91) have been trying this as well. Don't know if someone's fixed it yet.
Tom Beauford
2009-08-10, 01:29 PM
layerstate-restore (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67b6.htm) is just one of the 14 layerstate lisp commands listed in AutoCAD help.
Example: (layerstate-restore "CONTOURS")
You may have to do a regen afterwards.
<LI class=topiclist-litem>layerstate-addlayers (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67f2.htm)
Adds or updates a series of layers to a layer state
<LI class=topiclist-litem>layerstate-compare (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS73099cc142f487551ec84dc1111af5a7b7-7c9c.htm)
Compares a layerstate to the layers in the current drawing
<LI class=topiclist-litem>layerstate-delete (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67df.htm)
Deletes a layer state
<LI class=topiclist-litem>layerstate-export (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67bd.htm)
Exports a layer state to a specified file
<LI class=topiclist-litem>layerstate-getlastrestored (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS73099cc142f487551ec84dc1111af5a7b7-7c8f.htm)
Returns the name of the last restored layer state in the current drawing
<LI class=topiclist-litem>layerstate-getlayers (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67ca.htm)
Returns the layers saved in a layer state
<LI class=topiclist-litem>layerstate-getnames (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS73099cc142f487551ec84dc1111af5a7b7-7c8a.htm)
Returns a list of the layer state names
<LI class=topiclist-litem>layerstate-has (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67e5.htm)
Checks if a layer state is present
<LI class=topiclist-litem>layerstate-import (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67c3.htm)
Imports a layer state from a specified file
<LI class=topiclist-litem>layerstate-importfromdb (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ff1b508da11142adfd67-7f9c.htm)
Imports a layer state from a specified drawing file
<LI class=topiclist-litem>layerstate-removelayers (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ff1b508da11142adfd67-7f94.htm)
Removes a list of layers from a layer state
<LI class=topiclist-litem>layerstate-rename (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67d9.htm)
Renames a layer state
<LI class=topiclist-litem>layerstate-restore (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67b6.htm)
Restores a layer state into the current drawing
<LI class=topiclist-litem>layerstate-save (mk:@MSITStore:C:\Program%20Files\AutoCAD%20Map%203D%202009\help\acad_alr.chm::/WS1a9193826455f5ffd9a7a610ecb0483d5-67d2.htm)
Saves a layer state in the current drawing
irneb
2009-08-10, 02:09 PM
No, that's exactly the same as the command line's problem. It does not VPFreeze the layers, instead it simply Freezes them completely.
Tom Beauford
2009-08-10, 06:45 PM
No, that's exactly the same as the command line's problem. It does not VPFreeze the layers, instead it simply Freezes them completely.
Sorry, missed that. Try:
(layerstate-restore "CONTOURS" (vlax-vla-object->ename (vla-get-activepviewport (vla-get-activedocument (vlax-get-acad-object)))) 4)
Substitute your own layerstate name of course.
(layerstate-restore layerstatename viewport [restoreflags])
restoreflags set to 4 => Restore the layer state properties as viewport overrides (requires viewport to be not a nil value).
Sorry, missed that. Try:
(layerstate-restore "CONTOURS" (vlax-vla-object->ename (vla-get-activepviewport (vla-get-activedocument (vlax-get-acad-object)))) 4)
Substitute your own layerstate name of course.
(layerstate-restore layerstatename viewport [restoreflags])
restoreflags set to 4 => Restore the layer state properties as viewport overrides (requires viewport to be not a nil value).
This code works. Thanks!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.