<?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 Re: Setting PS Viewport Named View in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3283747#M57766</link>
    <description>&lt;P&gt;What I used was set layoutmanager.currentlayout to the name of the layout.&amp;nbsp; Then I forced the the viewport to be active&amp;nbsp;using setsystemvariable("tilemode",0).&amp;nbsp; Note that this worked for me because there is only 1 viewport in each of the&amp;nbsp;layouts.&amp;nbsp; If there was more than 1 viewport I logged an error and fixed it with other methods.&amp;nbsp; The example in the dev guide uses&amp;nbsp;the cvport and tilemode systemvariables, and then doc.editor.switchtomodelspace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the viewport is active, you can use something like "dim myviewtr as viewtablerecord = doc.editor.getcurrentview.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dev guide&amp;nbsp;info:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://docs.autodesk.com/ACD/2011/ENU/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3482.htm"&gt;http://docs.autodesk.com/ACD/2011/ENU/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3482.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to me that&amp;nbsp;there should be a better way.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2012 16:20:39 GMT</pubDate>
    <dc:creator>fieldguy</dc:creator>
    <dc:date>2012-01-06T16:20:39Z</dc:date>
    <item>
      <title>Setting PS Viewport Named View</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3282959#M57765</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have code that has the user select a viewport. &amp;nbsp;I then need to set the selected viewport to an existing view, but I cannot find any exampes of this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A couple of things that are confusing me...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the viewport, but how do I get the ViewPortTable/&lt;SPAN&gt;ViewPortTableRecord&lt;/SPAN&gt; from it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need to set the view in the ViewPortTableRecord od the ViewTableRecord?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No problems to this point...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'Code snip
If acPrmpt_res.Status = PromptStatus.OK Then

                    Dim acVPort As Viewport = Nothing
                    Dim acViewTbl As ViewTable
                    Dim acViewTblrec As ViewTableRecord
                    Dim acVPortTbl As ViewportTable
                    Dim acVPortTblRec As ViewportTableRecord
                    Dim acEnt As Entity = Nothing

                    For Each acObjId As ObjectId In acPrmpt_res.Value.GetObjectIds
                        acEnt = acObjId.GetObject(OpenMode.ForRead)
                        If TypeOf acEnt Is Viewport Then

                            acVPort = acObjId.GetObject(OpenMode.ForRead)
                            acVPort.Highlight()

                            'Set selected viewport named view here...

                        End If
                    Next
'Code snip&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Any help would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2012 23:30:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3282959#M57765</guid>
      <dc:creator>Rob.O</dc:creator>
      <dc:date>2012-01-05T23:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Setting PS Viewport Named View</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3283747#M57766</link>
      <description>&lt;P&gt;What I used was set layoutmanager.currentlayout to the name of the layout.&amp;nbsp; Then I forced the the viewport to be active&amp;nbsp;using setsystemvariable("tilemode",0).&amp;nbsp; Note that this worked for me because there is only 1 viewport in each of the&amp;nbsp;layouts.&amp;nbsp; If there was more than 1 viewport I logged an error and fixed it with other methods.&amp;nbsp; The example in the dev guide uses&amp;nbsp;the cvport and tilemode systemvariables, and then doc.editor.switchtomodelspace.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once the viewport is active, you can use something like "dim myviewtr as viewtablerecord = doc.editor.getcurrentview.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dev guide&amp;nbsp;info:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A target="_blank" href="http://docs.autodesk.com/ACD/2011/ENU/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3482.htm"&gt;http://docs.autodesk.com/ACD/2011/ENU/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3482.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems to me that&amp;nbsp;there should be a better way.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2012 16:20:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3283747#M57766</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2012-01-06T16:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Setting PS Viewport Named View</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3284397#M57767</link>
      <description>&lt;P&gt;I am very close now, but still having some issues...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to get the view to change with the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;For Each acObjId As ObjectId In acPrmpt_res.Value.GetObjectIds
                        acEnt = acObjId.GetObject(OpenMode.ForRead)
                        If TypeOf acEnt Is Viewport Then

                            acVPort = acObjId.GetObject(OpenMode.ForWrite)

                            Dim acVPNum As IntPtr = acVPort.Number
                            
                            '' Make selected viewport the current viewport
                            acedSetCurrentVPort(acVPort.UnmanagedObject)
                           
                            '' Activate model space in the viewport
                            acDoc.Editor.SwitchToModelSpace()

                            '' Get view table
                            acViewTbl = acTrans.GetObject(acCurDb.ViewTableId, OpenMode.ForRead)
                            acViewTblrec = acTrans.GetObject(acViewTbl(strViewName), OpenMode.ForWrite)

                            '' Set current view
                            acEd.SetCurrentView(acViewTblrec)&lt;/PRE&gt;&lt;P&gt;Works great with one exception... it's only changing the view in the last viewport that was activated and NOT in the viewport that was selected (acVport). &amp;nbsp;I thought I was activating (or seting current) the selected viewport with the acedSetCurrentVPort function, but it does not change the viewport.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try and pass the acVport.number as the value of acedSetCurrentVPort, I get an error: &amp;nbsp;"Attempting to read or write protected memory..."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I have left to figure out is how to change the current viewport to the one that was selected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas what I am doing wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2012 23:50:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3284397#M57767</guid>
      <dc:creator>Rob.O</dc:creator>
      <dc:date>2012-01-06T23:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Setting PS Viewport Named View</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3284993#M57768</link>
      <description>&lt;P&gt;This process should work for you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;acVPort = acObjId.GetObject(OpenMode.ForWrite)&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;acDoc.Editor.SwitchToModelSpace()&lt;/P&gt;&lt;P&gt;Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("CVPORT", acVPort.Number)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Do something with active viewport here...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Switch back to paper space...&lt;/P&gt;&lt;P&gt;acDoc.Editor.SwitchToPaperSpace()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also would be a good idea to check the 'Viewport.On' and 'Viewport.Locked' properties.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2012 02:29:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3284993#M57768</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2012-01-09T02:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Setting PS Viewport Named View</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3287355#M57769</link>
      <description>&lt;P&gt;Thanks CadMeUp... that worked great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why is it you cannot not set the viewport current prior to switching to modelspace? &amp;nbsp;I tried it, but no luck. &amp;nbsp;Just a curiosity as one of the unselected viewports will highlight as activated first (due to the acDoc.Editor.SwitchToModelSpace() function)&amp;nbsp;before the correct viewport is set with .SetSystemVariable("CVPORT", acVPort.Number). &amp;nbsp;Some users will inevitably get confused by this when seeing a viewport they did not select "highlight".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2012 18:17:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3287355#M57769</guid>
      <dc:creator>Rob.O</dc:creator>
      <dc:date>2012-01-10T18:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Setting PS Viewport Named View</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3290227#M57770</link>
      <description>&lt;P&gt;I know, it seems to work backwards and it is confusing in code. The help doc for the CVPORT system variable should make sense of it though:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="CVPORT Snippet.JPG" align="center" border="0" src="http://forums.autodesk.com/t5/image/serverpage/image-id/19029iBEC5090BB45DBE00/image-size/original?v=mpbl-1&amp;amp;px=-1" title="CVPORT Snippet.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2012 15:06:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-ps-viewport-named-view/m-p/3290227#M57770</guid>
      <dc:creator>cadMeUp</dc:creator>
      <dc:date>2012-01-12T15:06:50Z</dc:date>
    </item>
  </channel>
</rss>

