Dear Jeremy,
Thank you for the response. This looks like what I'm needing, but I'm having a problem getting it to work.
I have code to create the section cut for a ViewSection like this:
Document doc = revit.Application.ActiveUIDocument.Document;
//find a section view type
IEnumerable<ViewFamilyType> viewFamilyTypes = from elem in new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType))
let type = elem as ViewFamilyType
where type.ViewFamily == ViewFamily.Section
select type;
//create a BoundingBoxXYZ instance centered on wall
ElementCategoryFilter wallsFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
FilteredElementCollector collector = new FilteredElementCollector(doc);
IList<Element> walls = collector.WherePasses(wallsFilter).WhereElementIsNotElementType().ToElements();
Wall wall = (Wall)walls[0];
LocationCurve lc = wall.Location as LocationCurve;
Transform curveTransform = lc.Curve.ComputeDerivatives(0.5, true);
XYZ origin = curveTransform.Origin;
XYZ viewDirection = curveTransform.BasisX.Normalize();
XYZ normal = viewDirection.CrossProduct(XYZ.BasisZ).Normalize();
Transform transform = Transform.Identity;
transform.Origin = origin;
transform.BasisX = normal;
transform.BasisY = XYZ.BasisZ;
transform.BasisZ = normal.CrossProduct(XYZ.BasisZ);
BoundingBoxXYZ sectionBox = new BoundingBoxXYZ();
sectionBox.Transform = transform;
sectionBox.Min = new XYZ(-10, 0, 0);
sectionBox.Max = new XYZ(10, wall.get_Parameter(BuiltInParameter.WALL_USER_HEIGHT_PARAM).AsDouble(), 5);
//create section cut
ViewSection viewSection;
using (Transaction tx = new Transaction(doc))
{
tx.Start("SectionCut");
viewSection = ViewSection.CreateSection(doc, viewFamilyTypes.First().Id, sectionBox);
tx.Commit();
}
But it looks like to use the ExtrusionAnalyzer I need to break the ViewSection down into Solids through the GeometryElement, but when I try to retrieve the GeometryElement of the ViewSection I get a null. Here's my code that would get the GeometryElement and retrieve the Solids:
Autodesk.Revit.DB.Options geoOptions = doc.Application.Create.NewGeometryOptions();
geoOptions.ComputeReferences = true;
geoOptions.DetailLevel = ViewDetailLevel.Medium;
GeometryElement geoElem = viewSection.get_Geometry(geoOptions);
IEnumerator<GeometryObject> Objects1 = geoElem.GetEnumerator();
while (Objects1.MoveNext())
{
GeometryObject gobj = Objects1.Current;
Solid tSolid = gobj as Solid;
//use ExtrusionAnalyzer here
}
However geoElem is null. When I explore the section cut in Revit with RevitLookup it has a Geometry Field with <Geometry.Element> Value, but it is not bold and double-clicking on Geometry to Snoop further does nothing.
Am I doing something wrong here? Is there another way to get to the Solids of the ViewSection that I'm not seeing?
Sorry about generating two tickets for this one thread.
Thank you for your help.