Message 1 of 10
Trying to select PViewport objects

Not applicable
05-03-2007
10:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Greetings all.
I'm (very) new to VBA and I'm struggling along, but I'm completely confused now. Using the following code, I can create a new PViewport object but I can't select it. However, if I change the FilterData(0) variable to "Viewport", I can. That seems really wrong to me. Unforunately, it also picks up the master viewports (layout and modelspace) as well, which I don't want.
Can someone please explain how to select the viewports on a layout without picking the master viewports as well?
Thanks in anticipation,
Trevor
---
Sub Viewport_Test()
Dim VPSelection As AcadSelectionSet
Dim TestVP As AcadPViewport
Dim TVPCenter(2) As Double
Dim TVPWidth As Double
Dim TVPHeight As Double
'Create PViewport object
TVPCenter(0) = 30: TVPCenter(1) = 30: TVPCenter(2) = 0
TVPWidth = 50: TVPHeight = 40
Set TestVP = ThisDrawing.PaperSpace.AddPViewport(TVPCenter, TVPWidth, TVPHeight)
'Select Viewports
Set VPSelection = ThisDrawing.SelectionSets.Add("ABC")
Dim FilterType(1) As Integer
Dim FilterData(1) As Variant
FilterType(0) = 0: FilterData(0) = "Viewport"
FilterType(1) = 67: FilterData(1) = 1
Call VPSelection.Select(acSelectionSetAll, , , FilterType, FilterData)
'List Selection Set info
MsgBox ("There are now " + CStr(VPSelection.Count) + " objects in the Selection Set.")
'Clean up
TestVP.Delete
ThisDrawing.SelectionSets.Item("ABC").Delete
End Sub
I'm (very) new to VBA and I'm struggling along, but I'm completely confused now. Using the following code, I can create a new PViewport object but I can't select it. However, if I change the FilterData(0) variable to "Viewport", I can. That seems really wrong to me. Unforunately, it also picks up the master viewports (layout and modelspace) as well, which I don't want.
Can someone please explain how to select the viewports on a layout without picking the master viewports as well?
Thanks in anticipation,
Trevor
---
Sub Viewport_Test()
Dim VPSelection As AcadSelectionSet
Dim TestVP As AcadPViewport
Dim TVPCenter(2) As Double
Dim TVPWidth As Double
Dim TVPHeight As Double
'Create PViewport object
TVPCenter(0) = 30: TVPCenter(1) = 30: TVPCenter(2) = 0
TVPWidth = 50: TVPHeight = 40
Set TestVP = ThisDrawing.PaperSpace.AddPViewport(TVPCenter, TVPWidth, TVPHeight)
'Select Viewports
Set VPSelection = ThisDrawing.SelectionSets.Add("ABC")
Dim FilterType(1) As Integer
Dim FilterData(1) As Variant
FilterType(0) = 0: FilterData(0) = "Viewport"
FilterType(1) = 67: FilterData(1) = 1
Call VPSelection.Select(acSelectionSetAll, , , FilterType, FilterData)
'List Selection Set info
MsgBox ("There are now " + CStr(VPSelection.Count) + " objects in the Selection Set.")
'Clean up
TestVP.Delete
ThisDrawing.SelectionSets.Item("ABC").Delete
End Sub