Set Description for Layer State

Discussion in 'AutoCAD' started by Colin French, Feb 8, 2005.

  1. Colin French

    Colin French Guest

    Howdy Folks - My search didn't turn up anything but hopefully I'm overlooking something obvious.

    I can fiddle with layers and then save the layer state programatically using the LayerStateManager object as shown in the Help file. That saves the layers' information but not the Description of the layer state itself. Is there any way to do this?

    Thanks in advance for any help,

    ...Colin French
     
    Colin French, Feb 8, 2005
    #1
  2. Colin French

    Oberer Guest

    The help is non-existant, so hopefully others with more experience will chime in.

    I've not found a desc property, but what's wrong with being a little creative with the name?

    Code:
    Sub CreateLayerStates(LayerStateName As String, StatesToSave As Single)
    On Error GoTo myError
    Dim oLayerStateManager As AcadLayerStateManager
    Set oLayerStateManager = New AcadLayerStateManager
    oLayerStateManager.SetDatabase ThisDrawing.Database
    'oLayerStateManager.Delete LayerStateName
    oLayerStateManager.Save LayerStateName, StatesToSave
    Set oLayerStateManager = Nothing
    myEXIT:
    Exit Sub
    myError:
    Select Case Err.Number
    ' Layer state already exists.  delete it and resume
    Case -2145386475
    oLayerStateManager.Delete LayerStateName
    Err.Clear
    Resume
    Case Else
    MsgBox "Error Creating layer state:" & LayerStateName & _
    vbNewLine & Err.Number & Err.Description
    End Select
    Resume myEXIT
    End Sub
    
     
    Oberer, Feb 8, 2005
    #2
  3. Colin French

    Colin French Guest

    Thanks for the example - I'm able to save the layer states with no problem, the code in the Help file for 2005 *was* actually helpful for that, it's just adding that Description that eludes me at the moment.

    As you suggested, I'm trying to be as 'descriptive' as is reasonable with the names of the states. But it would be even better if I can explain what a state is used for with that Description property. It'll appear in the group's CAD manual, but who looks at those? <grin>

    Thanks again,

    ...Colin French
     
    Colin French, Feb 8, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.