Message 1 of 8
Creating Revit View Set from Scope Boxes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to create view sets of multiple areas in a model each with a plan, 2 sections and a section box 3D view. I intend to do this using scope boxes placed/copied manually, and do the rest with Revit API.
The first hurdle I've run into is that when I use the CreateSection on the boundingbox retrieved from the Scope Box, it points upward from below. I'm not sure why this is happening
Here is the code snippet I've used to create this:
public void CreateSection()
{
FilteredElementCollector scopeBoxes = new FilteredElementCollector(Document).OfCategory(BuiltInCategory.OST_VolumeOfInterest);
var scopeBoxList = scopeBoxes.ToList();
ViewFamilyType vft
= new FilteredElementCollector(Document)
.OfClass( typeof( ViewFamilyType ) )
.Cast<ViewFamilyType>()
.FirstOrDefault<ViewFamilyType>( x =>
ViewFamily.Section == x.ViewFamily );
using (Transaction tx = new Transaction(Document)) {
tx.Start("Create Section");
foreach (Element e in scopeBoxList)
{
BoundingBoxXYZ bbox = e.get_BoundingBox(null);
ViewSection section1 = ViewSection.CreateSection(Document, vft.Id, bbox);
}
tx.Commit();
}
}
I've tried creating a new bounding box, and assigning a new maximum and minimum point, intending to change the orientation while maintaining the dimensions, as below:
public void CreateSection()
{
FilteredElementCollector scopeBoxes = new FilteredElementCollector(Document).OfCategory(BuiltInCategory.OST_VolumeOfInterest);
var scopeBoxList = scopeBoxes.ToList();
ViewFamilyType vft
= new FilteredElementCollector(Document)
.OfClass( typeof( ViewFamilyType ) )
.Cast<ViewFamilyType>()
.FirstOrDefault<ViewFamilyType>( x =>
ViewFamily.Section == x.ViewFamily );
using (Transaction tx = new Transaction(Document)) {
tx.Start("Create Section");
foreach (Element e in scopeBoxList)
{
BoundingBoxXYZ bbox = e.get_BoundingBox(null);
/*ViewSection section1 = ViewSection.CreateSection(Document, vft.Id, bbox);*/
XYZ max1 = bbox.Max;
XYZ min1 = bbox.Min;
XYZ max2 = new XYZ(max1.X, max1.Y, min1.Z);
XYZ min2 = new XYZ(min1.X, min1.Y, max1.Z);
XYZ mid = bbox.Max.Add(bbox.Min)/2;
BoundingBoxXYZ ebbox = new BoundingBoxXYZ();
ebbox.Enabled = true;
ebbox.Max = max2;
ebbox.Min = min2;
ViewSection section2 = ViewSection.CreateSection(Document, vft.Id, ebbox);
}
tx.Commit();
}
}
However I get this error
