AcadLayerStateManager (VBA)

AcadLayerStateManager (VBA)

Anonymous
Not applicable
880 Views
5 Replies
Message 1 of 6

AcadLayerStateManager (VBA)

Anonymous
Not applicable
Hi to all of you, how can I freeze layers in a specific viewport in VBA (Topview-Frontview-Sideview-3DView)? Each viewport should have is own setting for each frozen layers. I tried several way, but the layer i would like to freeze, freeze in all viewport, and that what i do not want.

I try to use (AcadLayerStateManager), but I have no success to import a existing (____.las) file in my ''C'' drive.

Anyone have of you have a answer or a portion of a code?

Thank's in advance.
Marine Boy
0 Likes
881 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
I notice that the Layer State are loaded in the Layer State Manager, but not load in the drawing it shelf! Nothing was change at all in the drawing. I must select the right Layer State and apply (Restore) one by one. See my code.

Sub ChangeAllViewports_Click()


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

' Associate the current drawing database with LayerStateManager
oLSM.SetDatabase ThisDrawing.Database


ThisDrawing.ActivePViewport = viewportObj_Top
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\TopView.las"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_3D
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\3DView.las"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Front
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\FrontView.las"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Inside
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\InsideView.las"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Side
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\SideView.las"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Dummy
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\DummyView.las"
ThisDrawing.Regen (True)

End Sub
0 Likes
Message 3 of 6

Anonymous
Not applicable
Even with this, no change in the drawing. I still have to load them manually, one by one.

Sub ChangeAllViewports_Click()


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

' Associate the current drawing database with LayerStateManager
oLSM.SetDatabase ThisDrawing.Database


ThisDrawing.ActivePViewport = viewportObj_Top
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\TopView.las"
oLSM.Restore "TopView"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_3D
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\3DView.las"
oLSM.Restore "3DView"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Front
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\FrontView.las"
oLSM.Restore "FrontView"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Inside
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\InsideView.las"
oLSM.Restore "InsideView"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Side
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\SideView.las"
oLSM.Restore "SideView"
ThisDrawing.Regen (True)

ThisDrawing.ActivePViewport = viewportObj_Dummy
ThisDrawing.Regen (True)
oLSM.Import Application.ActiveDocument.Path & "\LayerDefault\DummyView.las"
oLSM.Restore "DummyView"
ThisDrawing.Regen (True)

End Sub
0 Likes
Message 4 of 6

Anonymous
Not applicable
search for VpLayerOff
0 Likes
Message 5 of 6

Anonymous
Not applicable
Take a look at this thread too

http://discussion.autodesk.com/thread.jspa?messageID=5451901

~'J'~
0 Likes
Message 6 of 6

Anonymous
Not applicable
Hi Bryco, thank's for the answer, but it's not working good for me. Y something simple, should be that hard to do? I will continue my search.

Marine Boy
0 Likes