Invalid number of references when creating a simple dimention in a family editor

Invalid number of references when creating a simple dimention in a family editor

dem1st
Enthusiast Enthusiast
2,029 Views
11 Replies
Message 1 of 12

Invalid number of references when creating a simple dimention in a family editor

dem1st
Enthusiast
Enthusiast

refin1.png

0 Likes
Accepted solutions (1)
2,030 Views
11 Replies
Replies (11)
Message 2 of 12

RPTHOMAS108
Mentor
Mentor

One reference is always an invalid number of references. You can't dimension a line from nowhere.

0 Likes
Message 3 of 12

dem1st
Enthusiast
Enthusiast
Thanks for responding! Im a little bit confused, please clarify things.
There's got to be 1 line and 2 Reference planes perpendicular to it,
correct?
0 Likes
Message 4 of 12

RPTHOMAS108
Mentor
Mentor

The reference array needs to contain at least two references one is from the line and the other is from that thing you want the line dimensioned from.

 

Depends on the types of references in terms of if they need to be parallel to one another or not i.e. in the UI you can dimension between whole line and end point of other line not parallel to first line.

0 Likes
Message 5 of 12

dem1st
Enthusiast
Enthusiast

Could you say what purpose does that line serve? Also, I'm not sure I understood what you meant by "that thing you want the line dimensioned from". My apologies if the questions are trivial, I've not worked with dimensions before. Thank you.

0 Likes
Message 6 of 12

RPTHOMAS108
Mentor
Mentor
Accepted solution

The 'Line' mentioned in Document.NewDimension argument is the dimension line i.e. the line where the dimension text is just above. Likely doesn't have to be the right length (i.e. matching overall dimension) is used as an alignment position, so could perhaps be a unit length.

 

Reference array contains references obtained from geometry that you want to dimension between. So if you dimension between two things you obtain the references of those two things (lines/grids/surfaces/points...) to put in the array. If you dimension between four things (as below) you obtain the references from those four things (it creates then a dimension with three dimension segments). Probably they need to be in the right order, I've not put them in the wrong order so can't say for sure.

 

211117.PNG

0 Likes
Message 7 of 12

dem1st
Enthusiast
Enthusiast

Awesome exanaion, makes sense. What if we are dealing with a reference plane and not a geometry element. While trying to get that reference of the reference plane compiler finds error saying there is no such member!?

dem1st_1-1637151784535.png

0 Likes
Message 8 of 12

RPTHOMAS108
Mentor
Mentor

I usually use 'New Reference(ReferencePlane)' for that rather than trying to get geometry from a reference plane, similar for grids.

0 Likes
Message 9 of 12

dem1st
Enthusiast
Enthusiast

Tried to do it with 'New Reference(ReferencePlane)'  and got an error. What can be the problem here? 

 

dem1st_0-1637178107516.png

 

0 Likes
Message 10 of 12

RPTHOMAS108
Mentor
Mentor

Are the reference planes parallel?

 

You can probably use ReferencePlane.GetReference your original error was likely due to using old sample code where GetReference used to be a property called ReferencePlane.Reference.

 

I think either way should lead to same result i.e. the references are not suitable in their current form to create a dimension (demonstrate in UI).

0 Likes
Message 11 of 12

dem1st
Enthusiast
Enthusiast

Plugin does create Reference planes but it doesn't go pass that point throwing same "ArgumentException: 'One of the conditions for the inputs was not satisfied"

dem1st_0-1637186898348.png

 

I assume that is because something is wrong with the line creation. Right?

 

 

                XYZ z1 = new XYZ(5, 5, 0);
                XYZ z2 = new XYZ(5, -5, 0);
                XYZ z3 = new XYZ(-5, -5, 0);
                XYZ z4 = new XYZ(-5, 5, 0);

                XYZ cutVec = new XYZ(0, 0, 5);
                ReferencePlane refplane1 = doc.FamilyCreate.NewReferencePlane(z1, z2, cutVec, doc.ActiveView);
                ReferencePlane refplane2 = doc.FamilyCreate.NewReferencePlane(z4, z3, cutVec, doc.ActiveView);

                XYZ pt1 = new XYZ(-5, 5, 0);
                XYZ pt2 = new XYZ(5, 5, 0);
//is the problem down below?
                Line lin = Line.CreateBound(pt1, pt2);

                ReferenceArray ra = new ReferenceArray();
                ra.Append(refplane1.GetReference());
                ra.Append(refplane2.GetReference());

                Dimension dim = doc.FamilyCreate.NewLinearDimension(doc.ActiveView, lin, ra);
0 Likes
Message 12 of 12

snajjar
Contributor
Contributor

@dem1st : Can you try Document.Regenerate() after creating the reference planes and before grabbing their reference, or maybe do those in 2 separate transactions. Sometimes Revit do not have full grasp of newly created geometry before the transaction is committed.

0 Likes