One reference is always an invalid number of references. You can't dimension a line from nowhere.
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.
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.
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.
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!?
I usually use 'New Reference(ReferencePlane)' for that rather than trying to get geometry from a reference plane, similar for grids.
Tried to do it with 'New Reference(ReferencePlane)' and got an error. What can be the problem here?
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).
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"
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);
@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.