<?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: Place viewport on sheet - Offset Issue in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13395515#M518</link>
    <description>&lt;P&gt;can you show us how are you looping?&lt;/P&gt;</description>
    <pubDate>Fri, 28 Mar 2025 06:26:06 GMT</pubDate>
    <dc:creator>Moustafa_K</dc:creator>
    <dc:date>2025-03-28T06:26:06Z</dc:date>
    <item>
      <title>AssemblyViewUtils.CreateDetailSection - isAssigned param disorganize the viewport layout</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13393050#M516</link>
      <description>&lt;P&gt;I plan to place 2 assembly viewports at the top left corner of a titleblock.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using the following code to create 1 viewport, everything works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var sectionView = AssemblyViewUtils.CreateDetailSection(TicketPopulatorCommand.doc, assemblyId, anchorView.SectionOrientation
?? AssemblyDetailViewOrientation.ElevationTop, anchorViewTemplate.Id, true);


FamilyInstance titleBlock = new FilteredElementCollector(TicketPopulatorCommand.doc)
.OfClass(typeof(FamilyInstance))
.OfCategory(BuiltInCategory.OST_TitleBlocks)
.WhereElementIsNotElementType()
.Where(x =&amp;gt; x.OwnerViewId == viewSheet.Id)
.Cast&amp;lt;FamilyInstance&amp;gt;()
.FirstOrDefault();
if (titleBlock == null) throw new Exception("No title block found on the sheet.");
BoundingBoxXYZ titleBlockBox = titleBlock.get_BoundingBox(viewSheet);
XYZ titleBlockMin = titleBlockBox.Min; // Bottom-left of title block
XYZ titleBlockMax = titleBlockBox.Max; // Top-right of title block
XYZ location = new XYZ(titleBlockMin.X, titleBlockMax.Y,0);
Viewport viewport = Viewport.Create(TicketPopulatorCommand.doc, viewSheet.Id, sectionView .Id, location);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mgutierrezBM9E9_1-1743039168868.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1482318iA04309DA59D2E831/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mgutierrezBM9E9_1-1743039168868.png" alt="mgutierrezBM9E9_1-1743039168868.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when looping on multiple views there is an offset that gets added to the next view port (in the sample below the viewport from above was passed in the second loop, therefore an offset has been added to that viewport).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mgutierrezBM9E9_0-1743039125609.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1482316iDF53C8E50F02F338/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mgutierrezBM9E9_0-1743039125609.png" alt="mgutierrezBM9E9_0-1743039125609.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way, on every loop the min and max value of the title block is the same:&lt;BR /&gt;{(-3.328760717, -4.658490202, 0.000000000)}&lt;BR /&gt;{(-1.754686650, -3.639971685, 0.000000000)}&lt;/P&gt;&lt;P&gt;I have no clue where the offset is coming from.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another examples when placing 3 viewports!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mgutierrezBM9E9_0-1743039510369.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1482322iE6F42B89DBCF7F3F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mgutierrezBM9E9_0-1743039510369.png" alt="mgutierrezBM9E9_0-1743039510369.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 17:58:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13393050#M516</guid>
      <dc:creator>mgutierrezBM9E9</dc:creator>
      <dc:date>2025-03-28T17:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Place viewport on sheet - Offset Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13395220#M517</link>
      <description>&lt;P&gt;Can someone from the autodesk dev team take a look into this. Apparently the api does not allow to palce multiple viewports at the same location. Can you confirm this please?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 00:53:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13395220#M517</guid>
      <dc:creator>mgutierrezBM9E9</dc:creator>
      <dc:date>2025-03-28T00:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Place viewport on sheet - Offset Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13395515#M518</link>
      <description>&lt;P&gt;can you show us how are you looping?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 06:26:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13395515#M518</guid>
      <dc:creator>Moustafa_K</dc:creator>
      <dc:date>2025-03-28T06:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: Place viewport on sheet - Offset Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13396616#M519</link>
      <description>&lt;P&gt;I'm not even looping, I'm just creating the assembly sheet:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FamilySymbol titleBlock = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol))
    .OfCategory(BuiltInCategory.OST_TitleBlocks).Cast&amp;lt;FamilySymbol&amp;gt;()
    .FirstOrDefault(tb =&amp;gt; tb.Name.Equals(ticketTemplate.Titleblockname, StringComparison.OrdinalIgnoreCase));
if (titleBlock == null) return MolinErrors.Shared.ThrowError($"Titleblock not found: {ticketTemplate.Titleblockname}",
    tg: tg, tr: tr);
ViewSheet viewsheet = AssemblyViewUtils.CreateSheet(doc, assembly.Id, titleBlock.Id);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I'm querying the titleblock placed on that sheet:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FamilyInstance titleBlockInstance = new FilteredElementCollector(TicketPopulatorCommand.doc)
    .OfClass(typeof(FamilyInstance))
    .OfCategory(BuiltInCategory.OST_TitleBlocks)
    .WhereElementIsNotElementType()
    .Where(x =&amp;gt; x.OwnerViewId == viewsheet.Id)
    .Cast&amp;lt;FamilyInstance&amp;gt;()
    .FirstOrDefault();
if (titleBlockInstance == null) throw new Exception("No title block found on the sheet.");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then I'm picking the top left corner of the titleblock:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                                BoundingBoxXYZ titleBlockBox = titleBlock.get_BoundingBox(viewsheet);
                                XYZ titleBlockMin = titleBlockBox.Min; // Bottom-left of title block
                                XYZ titleBlockMax = titleBlockBox.Max; // Top-right of title block
                                XYZ location = new XYZ(titleBlockMin.X, titleBlockMax.Y, titleBlockMax.Z);&lt;/LI-CODE&gt;&lt;P&gt;Finally I'm creating views and placing them onto the sheet:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ElementId mainViewId = TicketPopulatorApp.Shared.CreateView(ticketTemplate.AnchorViews.MainView, assembly.Id);
Viewport viewport = Viewport.Create(TicketPopulatorCommand.doc, viewsheet.Id, mainViewId, location);


ElementId bottomViewId = TicketPopulatorApp.Shared.CreateView(ticketTemplate.AnchorViews.BottomView, assembly.Id);
Viewport bottomVP = Viewport.Create(TicketPopulatorCommand.doc, viewsheet.Id, bottomViewId, location);&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is my CreateView method:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public ElementId CreateView(AnchorView anchorView, ElementId assemblyId) {
    if (TicketPopulatorCommand.doc == null) throw new Exception("Document can not be null");

    View anchorViewTemplate = new FilteredElementCollector(TicketPopulatorCommand.doc)
        .OfClass(typeof(View)).Cast&amp;lt;View&amp;gt;().FirstOrDefault(v =&amp;gt;
        v.IsTemplate &amp;amp;&amp;amp; v.Name == anchorView.ViewTemplateName);
    if (anchorViewTemplate == null) throw new Exception($"Template not found: {anchorView.ViewTemplateName}");
    ElementId anchorViewId = ElementId.InvalidElementId;

    switch (anchorView.IsSection)
    {
        case true:
            var sectionView = AssemblyViewUtils.CreateDetailSection(TicketPopulatorCommand.doc, assemblyId, anchorView.SectionOrientation
                ?? AssemblyDetailViewOrientation.ElevationTop, anchorViewTemplate.Id, true);
            anchorViewId = sectionView.Id;
            break;
        case false:
            var view3d = AssemblyViewUtils.Create3DOrthographic(TicketPopulatorCommand.doc, assemblyId, anchorViewTemplate.Id, true);
            anchorViewId = view3d.Id;
            break;
    }
    return anchorViewId;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 16:28:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13396616#M519</guid>
      <dc:creator>mgutierrezBM9E9</dc:creator>
      <dc:date>2025-03-28T16:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: Place viewport on sheet - Offset Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13396780#M520</link>
      <description>&lt;P&gt;it's crazy, but changing the last parameter from true to false fixed the issue!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var sectionView = AssemblyViewUtils.CreateDetailSection(TicketPopulatorCommand.doc, assemblyId, anchorView.SectionOrientation
?? AssemblyDetailViewOrientation.ElevationTop, anchorViewTemplate.Id, false);&lt;/LI-CODE&gt;&lt;P&gt;The documentation says the following description:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;isAssigned&lt;/SPAN&gt; Type:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;SystemBoolean&lt;/SPAN&gt;&lt;BR /&gt;If true, the template will be assigned; if false, the template will be applied.&lt;/P&gt;&lt;P&gt;Does someone mind elaborating more on that? I'm still confused how the true value affect the layout of the views.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 17:58:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/assemblyviewutils-createdetailsection-isassigned-param/m-p/13396780#M520</guid>
      <dc:creator>mgutierrezBM9E9</dc:creator>
      <dc:date>2025-03-28T17:58:00Z</dc:date>
    </item>
  </channel>
</rss>

