.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Viewport Using COM

1 REPLY 1
Reply
Message 1 of 2
flongsworth
295 Views, 1 Reply

Select Viewport Using COM

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
1 REPLY 1
Message 2 of 2
pellacad
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost