This issue was recently brought to my attention and I thought I'd pass it on in case anyone else has experienced this. The scenario is this:
Create a new layer in model space, freeze that layer, and then save a new layer state. If you then move to a viewport and use the Layer State Manager dialog to restore that layer state, the frozen layer will be set as VP Frozen in that viewport. This is by-design and is expected behavior; there is a distinction between restoring in paper space and restoring in model space and they are treated like the two different environments they are. The issue is that restoring a layer state using the -LAYER command does not produce the same results.
If you use -LAYER to restore the same layer state while in a viewport, it only restores the global freeze setting and does not apply the VP freeze setting for that layer. It seems the -LAYER command was not updated to be "aware" of viewports that you might be in at the time. Fortunately, there is a workaround.
If you prefer to restore layer states from the command line (rather than using the Layer State Manager dialog) you can use the (layerstate-restore) LISP function like so:
(layerstate-restore "mylayerstate" (acet-currentviewport-ename))
(acet-currentviewport-ename) is an Express Tools function that returns the entity ID of the viewport you're currently in. Using this in combination with the (layerstate-restore) function will restore the layer state to the current viewport with the same results as if you had used the Layer State Manager dialog.
Layer State LISP Functions
In case you were unaware of this layer state LISP function, let me take this opportunity to highlight all the others:
(layerstate-addlayers)
Adds/updates a series of layers to a layer state
(layerstate-compare)
Compares a layer state to the layers in the current drawing
(layerstate-delete)
Deletes a layer state
(layerstate-export)
Exports a layer state to an .LAS file
(layerstate-getlastrestored)
Returns the name of the last restored layer state in the current drawing
(layerstate-getlayers)
Returns a list of the layers saved in a layer state
(layerstate-getnames)
Returns a list of the layer state names in the drawing
(layerstate-has)
Checks if a layer state is present in the drawing
(layerstate-import)
Imports a layer state from a specified .LAS file
(layerstate-importfromdb)
Imports a layer state from a specified drawing file
(layerstate-removelayers)
Removes a list of layers from a layer state
(layerstate-rename)
Renames a layer state
(layerstate-restore)
Restores a layer state in the current drawing
(layerstate-save)
Saves a layer state in the current drawing
Most of these were introduced in AutoCAD 2008 (a couple were added in AutoCAD 2009) and they provide LISP access to the most common layer state operations. Check your AutoCAD help for specific usage details.
great information as always Tom. thanks for making time to share it with us.
Posted by: dave ea | February 24, 2010 at 03:17 PM