Posts: 17
Registered: ‎01-27-2005
Message 1 of 2 (108 Views)

Select Viewport Using COM

108 Views, 1 Replies
03-12-2006 02:53 PM
I am trying to select a viewport using com (since I still only have autocad 2005), The following is my code but no matter what I try I get nothing.
Right now I am trying to return just the ID of the vp, just to see if I can even pick it , but no luck.
Any ideas? Please help
Also, I am trying to do this from a form by pressing a button then hiding the form, if that has anything to do with it.

Dim COMDoc As Autodesk.AutoCAD.Interop.AcadDocument
COMDoc = COMApp.ActiveDocument
COMApp.Visible = True
COMDoc.Application.Visible = True
Dim SelSets As Autodesk.AutoCAD.Interop.AcadSelectionSets = COMDoc.SelectionSets
Dim NewSelSet As Autodesk.AutoCAD.Interop.AcadSelectionSet = Nothing
Dim ViewPort As Autodesk.AutoCAD.Interop.Common.AcadViewport
Dim ObjID As ObjectId

NewSelSet = SelSets.Add("TempSelSet")
Catch ex As Exception
NewSelSet = SelSets.Item("TempSelSet")
End Try
If Not NewSelSet Is Nothing Then
Dim Filtertype(0) As Short
Dim FilterData(0) As Object
NewSelSet.SelectOnScreen(Filtertype, FilterData)
For Each ent As Autodesk.AutoCAD.Interop.Common.AcadEntity In NewSelSet
If TypeOf ent Is Autodesk.AutoCAD.Interop.Common.AcadViewport Then
ViewPort = ent
ObjID = ent.Id
Exit For
End If
End If
Catch ex As Exception
MsgBox("Unable to get Selection Set")
End Try

MsgBox("The vp id is: " & ObjID.ToString)

COMDoc = Nothing
Catch ex As Exception

MsgBox("The following error occured: " & vbCrLf & ex.Message & vbCrLf & _
"Source: " & vbCrLf & ex.Source & vbCrLf & _
"Stack Trace: " & vbCrLf & ex.StackTrace)

End Try
Valued Contributor
Posts: 73
Registered: ‎04-19-2006
Message 2 of 2 (108 Views)

Re: Select Viewport Using COM

05-16-2008 08:28 AM in reply to: flongsworth
Greetings flongsworth,

Did you ever get a solution to your "Select Viewport" question.

I find myself needing to do this very thing as well.

Let me know if you have a solution to this problem.


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.