<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Select Viewport Using COM in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/select-viewport-using-com/m-p/1578883#M82419</link>
    <description>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.&lt;BR /&gt;
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.&lt;BR /&gt;
Any ideas? Please help&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
        Dim COMDoc As Autodesk.AutoCAD.Interop.AcadDocument&lt;BR /&gt;
        COMDoc = COMApp.ActiveDocument&lt;BR /&gt;
        COMApp.Visible = True&lt;BR /&gt;
        COMDoc.Application.Visible = True&lt;BR /&gt;
        Dim SelSets As Autodesk.AutoCAD.Interop.AcadSelectionSets = COMDoc.SelectionSets&lt;BR /&gt;
        Dim NewSelSet As Autodesk.AutoCAD.Interop.AcadSelectionSet = Nothing&lt;BR /&gt;
        Dim ViewPort As Autodesk.AutoCAD.Interop.Common.AcadViewport&lt;BR /&gt;
        Dim ObjID As ObjectId&lt;BR /&gt;
        Try&lt;BR /&gt;
&lt;BR /&gt;
            Me.Close()&lt;BR /&gt;
            Try&lt;BR /&gt;
                NewSelSet = SelSets.Add("TempSelSet")&lt;BR /&gt;
                NewSelSet.Clear()&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                NewSelSet = SelSets.Item("TempSelSet")&lt;BR /&gt;
                NewSelSet.Clear()&lt;BR /&gt;
            End Try&lt;BR /&gt;
            Try&lt;BR /&gt;
                If Not NewSelSet Is Nothing Then&lt;BR /&gt;
                    Dim Filtertype(0) As Short&lt;BR /&gt;
                    Dim FilterData(0) As Object&lt;BR /&gt;
                    NewSelSet.SelectOnScreen(Filtertype, FilterData)&lt;BR /&gt;
                    For Each ent As Autodesk.AutoCAD.Interop.Common.AcadEntity In NewSelSet&lt;BR /&gt;
                        If TypeOf ent Is Autodesk.AutoCAD.Interop.Common.AcadViewport Then&lt;BR /&gt;
                            ViewPort = ent&lt;BR /&gt;
                            ObjID = ent.Id&lt;BR /&gt;
                            Exit For&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    Next&lt;BR /&gt;
                End If&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                MsgBox("Unable to get Selection Set")&lt;BR /&gt;
            End Try&lt;BR /&gt;
&lt;BR /&gt;
            MsgBox("The vp id is: " &amp;amp; ObjID.ToString)&lt;BR /&gt;
&lt;BR /&gt;
            NewSelSet.Delete()&lt;BR /&gt;
            COMDoc = Nothing&lt;BR /&gt;
            Me.Close()&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
&lt;BR /&gt;
            MsgBox("The following error occured: " &amp;amp; vbCrLf &amp;amp; ex.Message &amp;amp; vbCrLf &amp;amp; _&lt;BR /&gt;
                "Source:  " &amp;amp; vbCrLf &amp;amp; ex.Source &amp;amp; vbCrLf &amp;amp; _&lt;BR /&gt;
                "Stack Trace: " &amp;amp; vbCrLf &amp;amp; ex.StackTrace)&lt;BR /&gt;
&lt;BR /&gt;
        End Try</description>
    <pubDate>Sun, 12 Mar 2006 22:53:47 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-03-12T22:53:47Z</dc:date>
    <item>
      <title>Select Viewport Using COM</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-viewport-using-com/m-p/1578883#M82419</link>
      <description>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.&lt;BR /&gt;
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.&lt;BR /&gt;
Any ideas? Please help&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
        Dim COMDoc As Autodesk.AutoCAD.Interop.AcadDocument&lt;BR /&gt;
        COMDoc = COMApp.ActiveDocument&lt;BR /&gt;
        COMApp.Visible = True&lt;BR /&gt;
        COMDoc.Application.Visible = True&lt;BR /&gt;
        Dim SelSets As Autodesk.AutoCAD.Interop.AcadSelectionSets = COMDoc.SelectionSets&lt;BR /&gt;
        Dim NewSelSet As Autodesk.AutoCAD.Interop.AcadSelectionSet = Nothing&lt;BR /&gt;
        Dim ViewPort As Autodesk.AutoCAD.Interop.Common.AcadViewport&lt;BR /&gt;
        Dim ObjID As ObjectId&lt;BR /&gt;
        Try&lt;BR /&gt;
&lt;BR /&gt;
            Me.Close()&lt;BR /&gt;
            Try&lt;BR /&gt;
                NewSelSet = SelSets.Add("TempSelSet")&lt;BR /&gt;
                NewSelSet.Clear()&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                NewSelSet = SelSets.Item("TempSelSet")&lt;BR /&gt;
                NewSelSet.Clear()&lt;BR /&gt;
            End Try&lt;BR /&gt;
            Try&lt;BR /&gt;
                If Not NewSelSet Is Nothing Then&lt;BR /&gt;
                    Dim Filtertype(0) As Short&lt;BR /&gt;
                    Dim FilterData(0) As Object&lt;BR /&gt;
                    NewSelSet.SelectOnScreen(Filtertype, FilterData)&lt;BR /&gt;
                    For Each ent As Autodesk.AutoCAD.Interop.Common.AcadEntity In NewSelSet&lt;BR /&gt;
                        If TypeOf ent Is Autodesk.AutoCAD.Interop.Common.AcadViewport Then&lt;BR /&gt;
                            ViewPort = ent&lt;BR /&gt;
                            ObjID = ent.Id&lt;BR /&gt;
                            Exit For&lt;BR /&gt;
                        End If&lt;BR /&gt;
                    Next&lt;BR /&gt;
                End If&lt;BR /&gt;
            Catch ex As Exception&lt;BR /&gt;
                MsgBox("Unable to get Selection Set")&lt;BR /&gt;
            End Try&lt;BR /&gt;
&lt;BR /&gt;
            MsgBox("The vp id is: " &amp;amp; ObjID.ToString)&lt;BR /&gt;
&lt;BR /&gt;
            NewSelSet.Delete()&lt;BR /&gt;
            COMDoc = Nothing&lt;BR /&gt;
            Me.Close()&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
&lt;BR /&gt;
            MsgBox("The following error occured: " &amp;amp; vbCrLf &amp;amp; ex.Message &amp;amp; vbCrLf &amp;amp; _&lt;BR /&gt;
                "Source:  " &amp;amp; vbCrLf &amp;amp; ex.Source &amp;amp; vbCrLf &amp;amp; _&lt;BR /&gt;
                "Stack Trace: " &amp;amp; vbCrLf &amp;amp; ex.StackTrace)&lt;BR /&gt;
&lt;BR /&gt;
        End Try</description>
      <pubDate>Sun, 12 Mar 2006 22:53:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-viewport-using-com/m-p/1578883#M82419</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-03-12T22:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Select Viewport Using COM</title>
      <link>https://forums.autodesk.com/t5/net-forum/select-viewport-using-com/m-p/1578884#M82420</link>
      <description>Greetings flongsworth,&lt;BR /&gt;
&lt;BR /&gt;
Did you ever get a solution to your "Select Viewport" question.&lt;BR /&gt;
&lt;BR /&gt;
I find myself needing to do this very thing as well.&lt;BR /&gt;
&lt;BR /&gt;
Let me know if you have a solution to this problem.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Pete</description>
      <pubDate>Fri, 16 May 2008 15:28:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/select-viewport-using-com/m-p/1578884#M82420</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-05-16T15:28:53Z</dc:date>
    </item>
  </channel>
</rss>

