Create.NewDimension – multiple reference errors (Invalid number of references, Line is not perpendicular, …) when pairing Grid curve ref with Column center ref

Create.NewDimension – multiple reference errors (Invalid number of references, Line is not perpendicular, …) when pairing Grid curve ref with Column center ref

pvamsikrishna736
Enthusiast Enthusiast
176 Views
0 Replies
Message 1 of 1

Create.NewDimension – multiple reference errors (Invalid number of references, Line is not perpendicular, …) when pairing Grid curve ref with Column center ref

pvamsikrishna736
Enthusiast
Enthusiast

 

Hi all,

I’m writing a Revit 2024 add-in that should auto-dimension every structural column to its nearest grid.

Full source (Visual Studio solution, command classes, collectors, etc.) is on GitHub:
https://github.com/vamsi736/FastTag

What I’m doing

Element Reference I take
Gridgrid.Curve.Reference (same one the UI uses when you click the grid line)
Columncolumn.GetReferences( FamilyInstanceReferenceType.CenterLeftRight or CenterFrontBack ).FirstOrDefault()
 

Then I place them in a ReferenceArray and call doc.Create.NewDimension.

Minimal code

 

 

using (Transaction tx = new Transaction(doc, "Test dim"))
{
tx.Start();

Grid g = verticalGrid; // any grid in view
FamilyInstance col = column; // HSS column

Reference gridRef = g.Curve.Reference; // ✔︎ not null
Reference colRef = col.GetReferences(
FamilyInstanceReferenceType.CenterLeftRight)
.FirstOrDefault(); // ✔︎ not null

ReferenceArray ra = new ReferenceArray();
ra.Append(gridRef);
ra.Append(colRef);

Line dimLine = BuildPerpLine(g, col); // confirmed perpendicular

Dimension dim = doc.Create.NewDimension(
activeView, dimLine, ra, dimType); // ⬅︎ FAILS

tx.Commit();
}

 

 

 

Exceptions I’ve hit

Message (ex.Message) When it shows up
“Invalid number of references.”most attempts with two refs above
“The reference line is not perpendicular to the reference.”if I swap LeftRight / FrontBack orientation
“Input references are not valid for a dimension.”sporadically when I tried Bottom or Origin refs
“Cannot obtain geometry reference.”when col.GetReferences(…) returns null
 

If I replace gridRef with a face reference (Options { ComputeReferences=true } → first face), the dimension is created successfully – but it disappears when grids are hidden, so I’d much rather keep the curve reference.

Questions

  1. Does NewDimension require the two refs to be of the same sub-type (edge-edge, plane-plane, etc.)?

  2. Is there a column reference (axis, face, extrusion edge?) that is compatible with grid.Curve.Reference?

  3. Is there a way to convert an edge/curve ref to a compatible “line” ref programmatically?

  4. Any other work-around to get a stable column-to-grid dimension that survives VV/workset toggles?

Revit 2024.2 • C# • .NET 4.8

Thanks a lot for any insight!

Full source (Visual Studio solution, command classes, collectors, etc.) is on GitHub:
https://github.com/vamsi736/FastTag

Sr. BIM Modeller,
Unibim Services pvt. ltd.
0 Likes
Replies (0)