Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: Restore a Layer State when opening/closing

  1. #11
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Restore a Layer State when opening/closing

    Quote Originally Posted by Opie View Post
    Quote Originally Posted by Tom Beauford View Post
    Layer States are simply a saved group of layer settings. They could be for every layer in the drawing, just one layer, or any group of layers in between. They do not have the ability to store viewport overrides, and they are not associated or linked to viewports in any way. I wrote a lisp to update current layers to match a Layer States file without adding any layers. Lisp could be written to only modify certain properties if say the only viewport overrides were viewport frozen, but it would not be possible to either save or restore setting for every viewport in every layout in a drawing.
    The code probably can be tweaked... What am I saying? We all know it can be tweaked. ...to provide a mechanism to assign a layer state to a viewport. Then trigger a layer state restore to restore the assigned layer state per viewport. If no layer state is assigned to the viewport, request the user to specify the desired layer state.
    I agree with the OP, that we *should* be able to update a Layer State once, and it affect all Viewports - and all drawings - that are associated with it (much like SSM, Fields before PLOT, PUBLISH, etc.).

    Unfortunately, that is just not how Autodesk designed them to work.

    As-is the current system manages per-Viewport layer settings (i.e., Layer States, VPLAYER, etc.) using the Viewport.FreezeLayersInViewport(), and Viewport.ThawLayersInViewport() Methods, which are not exposed to LISP.

    Separately, the Database.LayerStateManager Object manages the Layer States themselves, and can be associated with a View Object using the LayerState Property (string)... A Layout can also be associated with said View Object using the LayoutId Property (ObjectId). Difficulty here, is even if you go through those steps, this still doesn't actually update the Viewport(s) themselves.

    There's no existing mechanism that associates a Layer State and the Viewport(s) it has been applied to, one would have to be developed, as Opie aptly points out... An event-driven mechanism that 'updates' associated Viewport(s) automagically (via LayerState.GetViewportIds() Extension Method, as starting point?).

    Further complicating matters, is that it would appear that the LayerStateManager Object's own Events do not fire properly, with exception to LayerStateCreated Event (perhaps something's change in newer versions?)



    Some links for reference:

    Understanding How Layer States Get Restored

    LayerState Property (ActiveX)

    AutoCAD .NET LayerStateManager Events – Post Operations




    Quote Originally Posted by Opie View Post
    Quote Originally Posted by Tom Beauford View Post
    The lisp you found is probably almost as close as you are going to get. I found the lisp you referred to by BlackBox (coder extraordinaire!) at: http://forums.autodesk.com/t5/visual...s/td-p/4605561. It's posting etiquette to include credit to whoever wrote the code and helpful to all to provide a link to where you found it.
    We probably should update the forum FAQ with this etiquette, but I dislike having to spell out etiquette (and not just the word).
    Thanks, guys. *tips hat*



    Cheers
    Last edited by BlackBox; 2015-03-21 at 03:04 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Layer state to restore with script
    By stg in forum AutoCAD General
    Replies: 5
    Last Post: 2009-08-11, 01:49 PM
  2. Restore Layer State
    By DW2Whittle in forum CAD Management - General
    Replies: 0
    Last Post: 2008-06-11, 04:54 PM
  3. Keep current Layer Filter current while opening and closing
    By kathy71046 in forum AutoCAD General
    Replies: 8
    Last Post: 2007-05-24, 02:35 AM
  4. Replies: 8
    Last Post: 2006-10-11, 07:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •