Dimension.AreSegmentsEqual is always False

Dimension.AreSegmentsEqual is always False

michael-coffey
Advocate Advocate
619 Views
4 Replies
Message 1 of 5

Dimension.AreSegmentsEqual is always False

michael-coffey
Advocate
Advocate

Please explain why in the attached image, the property AreSegmentsEqual is False for the selected dimension string.   I believe this is a bug.  In addition, using the following code will actually set the string to not equal (another bug):

public void SetDimensionEqual()
{
	Document doc = this.ActiveUIDocument.Document;
	Dimension dim = doc.GetElement(new ElementId(1097689)) as Dimension;
	
	using (Transaction t = new Transaction(doc, "Set Dim Equal"))
	{
		t.Start();
		dim.AreSegmentsEqual = true;
		t.Commit();
	}
}

 

0 Likes
620 Views
4 Replies
Replies (4)
Message 2 of 5

RPTHOMAS108
Mentor
Mentor

When you add an equality to a dimension it adds a new hidden dimension object of category OST_Constraints. This can be shown with reveal constraints and if you pick this constraint element and show in lookup you'll see the property you speak of is set to true, the original dimension remains unset.

 

In order to create or remove an equality constraint you can set the property on the visible dimension. Perhaps this should be a function rather than a property? The property can also be set on the constraint object itself to remove it. 

 

Capture20200507.PNG

 

I'm finding that regardless of what lookup is reporting the following code is working to toggle the equality constraints on and off.

 

 

Dim LD As Dimension = Doc.GetElement(R)
LD.AreSegmentsEqual = Not LD.AreSegmentsEqual

 

 i.e. if this value was always false the above would never turn the equality constraint off which doesn't appear to be the case.

 

Message 3 of 5

michael-coffey
Advocate
Advocate

Thank you for replying.  Are you saying that the way this property works makes sense?  How are you supposed to know that the underlying constraint dimension is related to the original one?

0 Likes
Message 4 of 5

michael-coffey
Advocate
Advocate

I tried looking at GetDependentElements but neither seem to show the other as dependent.

0 Likes
Message 5 of 5

RPTHOMAS108
Mentor
Mentor

Upon further investigation I find that the value in lookup is as expected and the below also switches the constraints on and off.

 

 

 

LD.AreSegmentsEqual = True

 

 

 

 

In my view given the paragraph below the correct situation should be that the visible dimension object should not report the status of equality only have a function for creating an equality constraint. Currently the property acts as a toggle so you can set it to True to first add a constraint and then to True again to remove it. That seems wrong but is probably related to the fact the Dimension class represents both Dimensions and Constraints. i.e. it is valid to read such a property on a constraint object but not on a dimension (should be Read/Write on constraint and WriteOnly on dimension).

 

Filtering for constraints and matching the items in reference array may be an approach to identify if the elements are constrained. Note however that dimensions are not dependant on constraints and constraints are not dependant on dimensions. So you can delete either without affecting the counterpart (there is no actual relationship and so would not expect .GetDependantElements to report one). Probably every Revit user has encountered the following when deleting dimensions set to equality:

 

CaptureJJK.PNG

 

You can also do the converse by deleting the constraint in the UI. After doing so the visible dimension will still report equality until one of the segments is dragged (it becomes an indicator of equality at that moment only not a constraint).

 

You can review the ValueString (EQ), Value (Same for each segment) and ValueOverride (Empty) of each of the DimensionSegments to know if the Dimension was once constrained to equality. 

 

 

0 Likes