Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems automatically adding dimensions from a wall edge to opening edge (2022)

3 REPLIES 3
Reply
Message 1 of 4
ehall8CEK4
287 Views, 3 Replies

Problems automatically adding dimensions from a wall edge to opening edge (2022)

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.

Tags (3)
Labels (1)
3 REPLIES 3
Message 2 of 4
jeremy_tammik
in reply to: ehall8CEK4

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.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 4
ehall8CEK4
in reply to: jeremy_tammik

 

 

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.

Message 4 of 4
ehall8CEK4
in reply to: jeremy_tammik

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.

Post to forums  

Autodesk Design & Make Report