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

Handle random order from ConnectorManager.Connectors #1375

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Revit_Core_Engine/Query/LocationCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ public static BH.oM.Geometry.Line LocationCurveColumn(this FamilyInstance family

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();


//Thanks to Revit, the order of connectors from connectorManager.Connectors isn't always the same!
FraserGreenroyd marked this conversation as resolved.
Show resolved Hide resolved
//So, we need SortCollinear to maintain the same connector order each time we pull an object.
endPoints = endPoints.SortCollinear();

BH.oM.Geometry.Line line = BH.Engine.Geometry.Create.Line(endPoints[0], endPoints[1]);
List<BH.oM.Geometry.Line> result = new List<BH.oM.Geometry.Line>();

Expand Down
23 changes: 19 additions & 4 deletions Revit_Core_Engine/Query/OrientationAngle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
using BH.Engine.Adapters.Revit;
using BH.Engine.Geometry;
using BH.oM.Adapters.Revit.Settings;
using BH.oM.Physical.Elements;
using BH.oM.Base.Attributes;
using BH.oM.Geometry;
using BH.oM.Physical.Elements;
using System;
using System.ComponentModel;
using System.Linq;

namespace BH.Revit.Engine.Core
{
Expand Down Expand Up @@ -81,8 +81,23 @@ public static double OrientationAngle(this MEPCurve mepCurve, RevitSettings sett
// Get the End connector for this duct
if (conn.ConnectorType == ConnectorType.End)
{
connector = conn;
break;
if (connector == null)
{
connector = conn;
continue;
}

//Thanks to Revit, the order of connectors from connectorManager.Connectors isn't always the same!
//So, we need to get the connector whose origin has the smallest X,Y & Z values in order to measure OrientationAngle consistently.
XYZ p1 = connector.Origin;
XYZ p2 = conn.Origin;

if ((p1.X - p2.X) > Tolerance.Distance
|| (p1.Y - p2.Y) > Tolerance.Distance
|| (p1.Z - p2.Z) > Tolerance.Distance)
{
connector = conn;
}
}
}

Expand Down