I'm running into some problems with my revit plugin that doesn't seem to have a straightforward answer within the API. I'd like to automatically dimension the edge of a wall and the edge of an opening within an elevation view with a click of a button, but the method I first used doesn't work.
I tried iterating through the faces of the wall, seeing which ones were facing the right direction, and adding their .Reference to a ReferenceArray, but faces created by openings don't return References that way. I'm not seeing anything within the API related to openings and any references they might return.
Currently writing in C# for Revit 2022 with the intention to port to later versions.
How did yoiu obtain the opening geometry to iterate over the faces? If you call get_Geometry with the Options.ComputeReferences set to true, the geometry elements should come equipped with references that you can use.
Options options = new Options();
options.ComputeReferences = true;
options.IncludeNonVisibleObjects = true;
options.View = activeView;
GeometryElement wallGeometry = wall.get_Geometry(options);
foreach (GeometryObject geomObj in wallGeometry)
{
if (geomObj is Solid solid)
{
foreach (Face face in solid.Faces)
{
Hi @jeremy_tammik , I used the above options and the beginning of a for loop above to iterate faces. It's able to get the main wall faces (ends, tops and bottoms, exterior and interior) but once it starts iterating faces created by openings, the references aren't good anymore. Attempting to use .ConvertToStableReference (just to print to a TaskDialog to test) for those faces returns an error, and doc.Create.NewDimension doesn't recognize them as valid references (it does recognize the aforementioned main wall faces.
ALL references can be put into a ReferenceArray just fine, it just seems some are invalid.
Do you have any solutions or recommendations for how I should go about fixing this problem?
Can't find what you're looking for? Ask the community or share your knowledge.