Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectorManager.Connectors sometimes returns connectors in random orders #1374

Closed
vietle-bh opened this issue Jun 20, 2023 · 1 comment · Fixed by #1375
Closed

ConnectorManager.Connectors sometimes returns connectors in random orders #1374

vietle-bh opened this issue Jun 20, 2023 · 1 comment · Fixed by #1375
Assignees
Labels
type:bug Error or unexpected behaviour

Comments

@vietle-bh
Copy link
Contributor

vietle-bh commented Jun 20, 2023

Description:

We discovered during beta testing that the call to mepCurve.ConnectorManager.Connectors didn't always return connectors in the same order. This needs a fix to allow comparing objects for equality in unit tests.

Steps to reproduce:

Debugging the below will show the start and end point of the line switch positions randomly:

List<BH.oM.Geometry.Point> endPoints = connectors.Where(x => x.ConnectorType == ConnectorType.End).Select(x => x.Origin.PointFromRevit()).ToList();
List<BH.oM.Geometry.Point> midPoints = connectors.Where(x => x.ConnectorType != ConnectorType.End).Select(x => x.Origin.PointFromRevit()).ToList();
BH.oM.Geometry.Line line = BH.Engine.Geometry.Create.Line(endPoints[0], endPoints[1]);

Connectors flipped

Another problem due to this bug is in calculating the orientation angle of an MEP curve:

foreach (Connector conn in mepCurve.ConnectorManager.Connectors)
{
// Get the End connector for this duct
if (conn.ConnectorType == ConnectorType.End)
{
connector = conn;
break;

The same curve can report an angle of 360 or 0 degree, depending on which End connector Revit randomly sees first.

Expected behaviour:

We need to sort connectors consistently so that pulling the same object always produces:

  • connectors in the same order
  • a consistent orientation angle value.

Test file(s):

@vietle-bh vietle-bh added the type:bug Error or unexpected behaviour label Jun 20, 2023
@vietle-bh vietle-bh self-assigned this Jun 20, 2023
@vietle-bh
Copy link
Contributor Author

FYI @travispotterBH 😱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error or unexpected behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant