Restore a view

Restore a view

Anonymous
Not applicable
183 Views
2 Replies
Message 1 of 3

Restore a view

Anonymous
Not applicable
How do you restore a named view once it's been added? I saved it with

Dim oMyView As AcadView
Set oMyView = ThisDrawing.Views.Add("MyView")

and I can't figure out how to restore it.

TIA

Have a day 😐
Roi Ledford
0 Likes
184 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Roi,

You must use the SETVIEW method

From VBA help :

Sub Example_SetView()
' This example creates a new view.
' It then changes the active viewport to
' the newly created view.

' First, open a sample drawing.
ThisDrawing.Application.Documents.Open "C:\AutoCAD\Sample\campus.dwg"

' Create a new view
Dim viewObj As AcadView
Set viewObj = ThisDrawing.Views.Add("TESTVIEW")

' Set the view characteristics

viewObj.center(0) = 374: viewObj.center(1) = 313
viewObj.width = 450
viewObj.height = 354

' Get the current active viewport
Dim viewportObj As AcadViewport
Set viewportObj = ThisDrawing.ActiveViewport
MsgBox "Change to the saved view.", , "SetView Example"

' Set the view in the viewport
viewportObj.SetView viewObj
ThisDrawing.ActiveViewport = viewportObj

ThisDrawing.Regen True

End Sub

Bernard
ATC
45700 Villemandeur
France
Roi Ledford a écrit dans le message :
9330C81F18EF75B897F30F450E5CA135@in.WebX.maYIadrTaRb...
> How do you restore a named view once it's been added? I saved it with
>
> Dim oMyView As AcadView
> Set oMyView = ThisDrawing.Views.Add("MyView")
>
> and I can't figure out how to restore it.
>
> TIA
>
> Have a day 😐
> Roi Ledford
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
Hi Bernard,

Thanks for the answer and sorry it took so long to get back.

--
Have a day 😐
Roi Ledford
"For lucky good wash, use Mr. Sparkle!"
---------------------------------
"Bernard Flavignard" wrote in message
news:250EC38CF0BF182131161E8890329D99@in.WebX.maYIadrTaRb...
> Roi,
>
> You must use the SETVIEW method
>
> From VBA help :
>
> Sub Example_SetView()
> ' This example creates a new view.
> ' It then changes the active viewport to
> ' the newly created view.
>
> ' First, open a sample drawing.
> ThisDrawing.Application.Documents.Open "C:\AutoCAD\Sample\campus.dwg"
>
> ' Create a new view
> Dim viewObj As AcadView
> Set viewObj = ThisDrawing.Views.Add("TESTVIEW")
>
> ' Set the view characteristics
>
> viewObj.center(0) = 374: viewObj.center(1) = 313
> viewObj.width = 450
> viewObj.height = 354
>
> ' Get the current active viewport
> Dim viewportObj As AcadViewport
> Set viewportObj = ThisDrawing.ActiveViewport
> MsgBox "Change to the saved view.", , "SetView Example"
>
> ' Set the view in the viewport
> viewportObj.SetView viewObj
> ThisDrawing.ActiveViewport = viewportObj
>
> ThisDrawing.Regen True
>
> End Sub
>
> Bernard
> ATC
> 45700 Villemandeur
> France
> Roi Ledford a écrit dans le message :
> 9330C81F18EF75B897F30F450E5CA135@in.WebX.maYIadrTaRb...
> > How do you restore a named view once it's been added? I saved it with
> >
> > Dim oMyView As AcadView
> > Set oMyView = ThisDrawing.Views.Add("MyView")
> >
> > and I can't figure out how to restore it.
> >
> > TIA
> >
> > Have a day 😐
> > Roi Ledford
> >
>
0 Likes