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

Select Viewport Using COM

107 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 (107 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
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!