Invalid Number of references

Invalid Number of references

chau.nguyen92
Participant Participant
1,090 Views
3 Replies
Message 1 of 4

Invalid Number of references

chau.nguyen92
Participant
Participant

Hi I wanted to create an aligned dimension. I followed exactly as Revit API docs:

 

Autodesk.Revit.DB.Line line = Autodesk.Revit.DB.Line.CreateBound(location1, location2);

ReferenceArray refArray = new ReferenceArray();

refArray.Append(line.GetEndPointReference(0));
refArray.Append(line.GetEndPointReference(1));


doc.Create.NewDimension(
doc.ActiveView, line, refArray);

 

However, I received error Invalid Number of references. I used revit 2018.2 

I have searched for this problems and see solutions on other forums. I tried to cast the start point and end point to reference but still receive the same error. Thanks in advance!

 

0 Likes
Accepted solutions (1)
1,091 Views
3 Replies
Replies (3)
Message 2 of 4

MarryTookMyCoffe
Collaborator
Collaborator

in revit lookup you can see that reference is null, use start point and end point

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
0 Likes
Message 3 of 4

RPTHOMAS108
Mentor
Mentor
Accepted solution

Just as in the UI I don't think you can dimension a line that isn't from actual geometry.

 

i.e. you need to create a DetailLine or ModelLine (both derive from CurveElement) and add the references to the array from those i.e.

 

Document.Create.NewDetailCurve(View, Line)

or

Document.Create.NewModelCurve(Curve, SketchPlane)

 

Then

CurveElement.GeometryCurve.GetEndPointReference(EndIndex)

0 Likes
Message 4 of 4

chau.nguyen92
Participant
Participant

Yeah I tried different ways. Tried what MarryTookMyCoffee suggested but only adding new detailcurve works. Odd that the Revit API example not working. Thanks

0 Likes