.NET

Reply
Contributor
flongsworth
Posts: 17
Registered: ‎01-27-2005
Message 1 of 2 (97 Views)

Select Viewport Using COM

97 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
Try

Me.Close()
Try
NewSelSet = SelSets.Add("TempSelSet")
NewSelSet.Clear()
Catch ex As Exception
NewSelSet = SelSets.Item("TempSelSet")
NewSelSet.Clear()
End Try
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
Next
End If
Catch ex As Exception
MsgBox("Unable to get Selection Set")
End Try

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

NewSelSet.Delete()
COMDoc = Nothing
Me.Close()
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
pellacad
Posts: 73
Registered: ‎04-19-2006
Message 2 of 2 (97 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.

Thanks!

Pete

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community