Author Topic: How do you delete a LayerState?  (Read 5809 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: How do you delete a LayerState?
« Reply #15 on: September 11, 2006, 05:21:46 PM »
How do I find that?
In the help, developers guide, VBA ActiveX reference, objects, LayerStateManager
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: How do you delete a LayerState?
« Reply #16 on: September 11, 2006, 05:24:18 PM »
Here's a quick example for 2007:
Code: [Select]
Sub LS_test()
    Dim oLSM As AcadLayerStateManager

    Set oLSM = ThisDrawing.Application. _
       GetInterfaceObject("AutoCAD.AcadLayerStateManager.17")

    oLSM.SetDatabase ThisDrawing.Database
    On Error Resume Next
    oLSM.Delete "abcd"
    If Err Then
        MsgBox "Layerstate not found...."
        Err.Clear
    Else
        ThisDrawing.Utility.Prompt vbCr & "Layerstate {abcd} deleted."
    End If
       
End Sub

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: How do you delete a LayerState?
« Reply #17 on: September 11, 2006, 05:27:10 PM »
Thanks Jeff.  I haven't used the ThisDrawing.Application area much.  I need to explore that area.

T.W. - does it tell you where its found in code? (I haven't looked it up yet)  Looking in the developer guide is great only if it tells you where to find it in the IDE
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Matersammichman

  • Guest
Re: How do you delete a LayerState?
« Reply #18 on: September 12, 2006, 07:39:35 AM »
You guys have been such a great help to me, let me share this.
What I wanted to do was create a LayerState named "Temp" that I could save, and overwrite as needed. Here is the completed blurb of code in ADT2005)
Code: [Select]
Private Sub cmdTLS_Click()
On Error Resume Next
    Dim colLayers As AcadLayers
    Dim objDict As AcadDictionary
    Dim objLayerStates As AcadDictionary
    Dim objXrec As AcadXRecord
   
    Set colLayers = ThisDrawing.Layers
    If colLayers.HasExtensionDictionary Then
       Set objDict = colLayers.GetExtensionDictionary
       Set objLayerStates = objDict("Acad_LayerStates")
       objLayerStates("temp").Delete
   End If

'''
Dim oLSM As AcadLayerStateManager
    ' Access the LayerStateManager object
   
    Set oLSM = ThisDrawing.Application. _
       GetInterfaceObject("AutoCAD.AcadLayerStateManager.16")

    ' Associate the current drawing database with LayerStateManager
    oLSM.SetDatabase ThisDrawing.Database
oLSM.Save "Temp", acLsOn + acLsFrozen + acLsLocked

Me.hide
End Sub
« Last Edit: September 12, 2006, 09:44:03 AM by CmdrDuh »