<?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: Adding a View (viewTableRecord) to Paper Space Layout in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755713#M51545</link>
    <description>&lt;P&gt;ViewTableRecord.IsPaperspaceView = true can help you&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jan 2013 17:08:14 GMT</pubDate>
    <dc:creator>Alexander.Rivilis</dc:creator>
    <dc:date>2013-01-17T17:08:14Z</dc:date>
    <item>
      <title>Adding a View (viewTableRecord) to Paper Space Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3754941#M51542</link>
      <description>&lt;P&gt;I have used the following code in a small app to create named views: &lt;A href="http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html?url=WS1a9193826455f5ff2566ffd511ff6f8c7ca-4325.htm,topicNumber=d0e6191" target="_blank"&gt;LINK_TO_Autodesk_Help_Topic&lt;/A&gt;&lt;/P&gt;&lt;P&gt;HOWEVER...A user of mine tried running the command while in a paper space layout.&amp;nbsp; It appears the view still gets created but only within Model Space.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The help DOES SAY that "a default model space view is created", but how would I specify that I want the view to be created within the "current" layout, either Model or Paper space?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried setting the .OwnerID property of the ViewTableRecord to "doc.CurrentSpaceID" but that did not work - no error either.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2013 21:15:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3754941#M51542</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-16T21:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a View (viewTableRecord) to Paper Space Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755214#M51543</link>
      <description>&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;&lt;P&gt;See article here&lt;/P&gt;&lt;P&gt;&lt;A href="http://adndevblog.typepad.com/autocad/2012/08/create-paper-space-viewports.html" target="_blank"&gt;http://adndevblog.typepad.com/autocad/2012/08/create-paper-space-viewports.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here is a code very quickly translated on C#:&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("VW")]
        public void tryCreateViewPort()
        {
            // Only works in paperspace
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    ObjectId mCurViewportId = ed.ActiveViewportId; 

                    if (mCurViewportId == ObjectId.Null)
                    {
                        ed.WriteMessage("\nCommand only works in paperspace.");

                        return;

                    }

                    Viewport pCurViewport = tr.GetObject(mCurViewportId, OpenMode.ForRead) as Viewport;

                    if (pCurViewport == null)
                    {

                        ed.WriteMessage("\nCannot get active viewport.");

                        return;

                    }

                    if (pCurViewport.Number != 1)
                    {

                        ed.WriteMessage("\nCommand only works in paperspace.");

                        return;

                    }

                    // Ask for the position

                    Point3d pt1; Point3d pt2;

                    pt1 = ed.GetPoint("\nSelect first corner: ").Value;
             
                    pt2 = ed.GetCorner("\nSelect second corner: ", pt1).Value;
       
                    // Ask for the view to use

                    string mViewName;

                    mViewName = ed.GetString("\nEnter name of view to use: ").StringResult;
                
                    // Create new viewport

                    Viewport pViewport = new Viewport();

                    pViewport.Width = Math.Abs(pt2.X - pt1.X);

                    pViewport.Height = Math.Abs(pt2.Y - pt1.Y);

                    pViewport.CenterPoint = new Point3d(

                      pt1.X + (pt2.X - pt1.X) / 2,

                      pt1.Y + (pt2.Y - pt1.Y) / 2,

                      pt1.Z);

                    // Append new viewport to paper space

                    BlockTable pTable;

                    BlockTableRecord pPsBTR;

                    pTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                    pPsBTR = (BlockTableRecord)tr.GetObject(pTable[BlockTableRecord.PaperSpace], OpenMode.ForWrite);

                    ObjectId mViewPortId = pPsBTR.AppendEntity(pViewport);

                    tr.AddNewlyCreatedDBObject(pViewport, true);
                    pViewport.On = true;
                    pViewport.FastZoomOn = true;

                    pViewport.SetUcs(pViewport.CenterPoint, Vector3d.XAxis, Vector3d.YAxis);
               

                    // Set the view

                    

                    ViewTable pViewTable = (ViewTable)tr.GetObject(db.ViewTableId, OpenMode.ForRead);
                  
                    // initialize the layout

                   // Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 0);
                  //  Layout layout = tr.GetObject(pPsBTR.LayoutId, OpenMode.ForWrite) as Layout;
                    //  LayoutManager.Current.CurrentLayout = "Layout2";
                    // layout.Initialize();

                    ViewTableRecord pViewTR;
                    if (pViewTable.Has(mViewName))
                    {
                        pViewTR = (ViewTableRecord)tr.GetObject(pViewTable[mViewName], OpenMode.ForWrite);
                    }
                    else
                    {
                        pViewTR = new ViewTableRecord();
                        pViewTR.Name = mViewName;
                        pViewTR.IsPaperspaceView = true;
                        pViewTable.UpgradeOpen();
                        ObjectId vtId = pViewTable.Add(pViewTR);

                        tr.AddNewlyCreatedDBObject(pViewTR, true);
                    }
                    

                    ed.SetCurrentView(pViewTR);

                    tr.Commit();

                    Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("TILEMODE", 0);
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                ed.WriteMessage(ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 08:19:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755214#M51543</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-01-17T08:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a View (viewTableRecord) to Paper Space Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755621#M51544</link>
      <description>&lt;P&gt;I really appreciate you taking the time to reply but...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your post and the link refer to a paper space "Viewport" like you do manually with the "MVIEW" command. What I needed to do was create a "View" in paper space like you do manually with the "VIEW" command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 15:47:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755621#M51544</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-17T15:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a View (viewTableRecord) to Paper Space Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755713#M51545</link>
      <description>&lt;P&gt;ViewTableRecord.IsPaperspaceView = true can help you&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 17:08:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755713#M51545</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2013-01-17T17:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a View (viewTableRecord) to Paper Space Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755893#M51546</link>
      <description>&lt;P&gt;This is the same in my code:&lt;/P&gt;&lt;PRE&gt;pViewTR.IsPaperspaceView = true;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 20:39:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755893#M51546</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-01-17T20:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a View (viewTableRecord) to Paper Space Layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755912#M51547</link>
      <description>&lt;P&gt;That was easy!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both Hallex and Alexander!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jan 2013 20:54:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/adding-a-view-viewtablerecord-to-paper-space-layout/m-p/3755912#M51547</guid>
      <dc:creator>MarkSanchezSPEC</dc:creator>
      <dc:date>2013-01-17T20:54:10Z</dc:date>
    </item>
  </channel>
</rss>

