<?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: How to add views on a sheet in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937115#M50824</link>
    <description>&lt;P&gt;View on sheet is Viewport (or ScheduleSheetInstance for schedule views). Find appropriate viewport on the sheet and delete it (via Document.Delete method)&lt;/P&gt;</description>
    <pubDate>Tue, 17 Apr 2018 06:47:47 GMT</pubDate>
    <dc:creator>aignatovich</dc:creator>
    <dc:date>2018-04-17T06:47:47Z</dc:date>
    <item>
      <title>How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7935024#M50820</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I'm trying to create an add-in, where a user&amp;nbsp;will be able to add all selected views on a sheet. I looked at &lt;A href="http://thebuildingcoder.typepad.com/blog/2008/10/relationship-in.html" target="_blank"&gt;viewports on sheets&lt;/A&gt; post on thebuildingcoder. But I wasn't able to find a solution to add views on sheet programmatically&amp;nbsp;(via API). I would like to know, can we achieve this functionality via API? would appreciate any help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ali Asad&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 12:25:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7935024#M50820</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-16T12:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7935114#M50821</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Look at static Viewport.Create method. Pass document, ids of viewsheet and your view and insertion point in sheet coordinates.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 12:55:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7935114#M50821</guid>
      <dc:creator>aignatovich</dc:creator>
      <dc:date>2018-04-16T12:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7935252#M50822</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1257478"&gt;@aignatovich&lt;/a&gt;. The solution works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 13:43:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7935252#M50822</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-16T13:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937077#M50823</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1257478"&gt;@aignatovich&lt;/a&gt;&amp;nbsp;Is there any way to remove the views from sheets? does API provides any method for it?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 06:36:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937077#M50823</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-17T06:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937115#M50824</link>
      <description>&lt;P&gt;View on sheet is Viewport (or ScheduleSheetInstance for schedule views). Find appropriate viewport on the sheet and delete it (via Document.Delete method)&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 06:47:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937115#M50824</guid>
      <dc:creator>aignatovich</dc:creator>
      <dc:date>2018-04-17T06:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937136#M50825</link>
      <description>&lt;P&gt;I see. that makes sense. So, I'll need to find the appropriate viewport that holds the reference of a view ID and sheet ID, thank you again&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1257478"&gt;@aignatovich&lt;/a&gt;&amp;nbsp;for making sense of this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 06:53:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937136#M50825</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-17T06:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to add views on a sheet</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937289#M50826</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1257478"&gt;@aignatovich&lt;/a&gt;&amp;nbsp;I've used your solution to get the appropriate viewport first, delete it and then add the view&amp;nbsp;to the sheet by using the following code. but the solution didn't work for me. because The&amp;nbsp;&lt;STRONG&gt;CanAddViewToSheet&lt;/STRONG&gt;() method in the following code returns false.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would appreciate if you look at it, and share your thoughts on how can I add views on sheet. Thank you&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;&lt;PRE&gt;        public static void MoveViewOnSheet(View view, Sheet sheet, Document doc)
        {
            var revitView = doc.GetElement(view.ElementID) as ViewPlan;
            var revitSheet = doc.GetElement(sheet.ElementID) as ViewSheet;


            // Get all viewports
            foreach (Viewport vp in (new FilteredElementCollector(doc).OfClass(typeof(Viewport))))
            {
                // Get those viewport which matches the viewid
                if (vp.ViewId.ToString().Contains(revitView.Id.ToString()))
                {
                    // Delete the viewport
                    using (Transaction transaction = new Transaction(doc, "Remove viewport"))
                    {
                        
                            transaction.Start();
                             doc.Delete(vp.Id);
                            transaction.Commit();


                    }
                }
            }


            // Map the view on sheet
            using (Transaction transaction = new Transaction(doc, "Mapping views on sheet"))
            {
                
                if (Viewport.CanAddViewToSheet(doc, revitSheet.Id, revitView.Id))
                {

                    transaction.Start();
                    Viewport.Create(doc, revitSheet.Id, revitView.Id, XYZ.Zero);
                    transaction.Commit();

                }

            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 08:00:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-add-views-on-a-sheet/m-p/7937289#M50826</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-04-17T08:00:08Z</dc:date>
    </item>
  </channel>
</rss>

