Message 1 of 5
AssemblyViewUtils.CreateDetailSection - isAssigned param disorganize the viewport layout
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I plan to place 2 assembly viewports at the top left corner of a titleblock.
When using the following code to create 1 viewport, everything works fine:
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 => x.OwnerViewId == viewSheet.Id)
.Cast<FamilyInstance>()
.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);
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).
By the way, on every loop the min and max value of the title block is the same:
{(-3.328760717, -4.658490202, 0.000000000)}
{(-1.754686650, -3.639971685, 0.000000000)}
I have no clue where the offset is coming from.
Another examples when placing 3 viewports!
