Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Feb 28, 2023
2 parents 0b38b5d + 39b7d58 commit 58f2bfc
Show file tree
Hide file tree
Showing 18 changed files with 883 additions and 223 deletions.
1 change: 1 addition & 0 deletions .idea/.idea.OpenMEP/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 63 additions & 2 deletions OpenMEP/ConnectorManager/Connector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ public static double Radius(Autodesk.Revit.DB.Connector connector)
.ConnectorManager?
.Connectors;
}

if (e is FabricationPart)
{
return ((FabricationPart) e)?
.ConnectorManager?
.Connectors;
}
return null;
}

Expand Down Expand Up @@ -300,7 +305,7 @@ public static double Radius(Autodesk.Revit.DB.Connector connector)
public static List<Autodesk.Revit.DB.Connector?> GetUsedConnectors(Revit.Elements.Element? element)
{
if (element == null) throw new ArgumentNullException(nameof(element));
if (GetConnectors(element).Any()) return new List<Autodesk.Revit.DB.Connector?>();
if (!GetConnectors(element).Any()) return new List<Autodesk.Revit.DB.Connector?>();
return GetConnectors(element).Where(x => x!.IsConnected).ToList();
}

Expand Down Expand Up @@ -883,4 +888,60 @@ public static Autodesk.Revit.DB.Connector ConnectTo(Autodesk.Revit.DB.Connector
CoordinateSystem coordinateSystem = Autodesk.DesignScript.Geometry.CoordinateSystem.ByOriginVectors(point, X, Y, Z);
return OpenMEPSandbox.Geometry.CoordinateSystem.Display(coordinateSystem,length);
}

/// <summary>
/// Identifies if the connector is connected to the specified connector.
/// </summary>
/// <param name="connector">the connector to check</param>
/// <param name="connectorOther">the second connector to identifies</param>
/// <returns name="bool">true if connector is connected to other</returns>
public static bool IsConnectedTo(Autodesk.Revit.DB.Connector connector,Autodesk.Revit.DB.Connector connectorOther)
{
return connector.IsConnectedTo(connectorOther);
}

// /// <summary>Gets fabrication connectivity information.</summary>
// /// <para name="connector">the connector</para>
// /// <since>2016</since>
// [MultiReturn("BodyConnectorId", "DoubleWallConnectorId", "FabricationIndex", "IsBodyConnectorLocked",
// "IsDoubleWallConnectorLocked", "HasDoubleWallConnector", "IsValid")]
// public static Dictionary<string, object?> GetFabricationConnectorInfo(Autodesk.Revit.DB.Connector connector)
// {
// if (connector == null) throw new ArgumentException(nameof(connector));
// FabricationConnectorInfo fabricationConnectorInfo = connector.GetFabricationConnectorInfo();
// if (fabricationConnectorInfo == null)
// {
// return new Dictionary<string, object?>
// {
// {"BodyConnectorId", null},
// {"DoubleWallConnectorId", null},
// {"FabricationIndex", null},
// {"IsBodyConnectorLocked", null},
// {"IsDoubleWallConnectorLocked", null},
// {"HasDoubleWallConnector", null},
// {"IsValid", null}
// };
// }
// int? DoubleWallConnectorId = null;
// bool? IsDoubleWallConnectorLocked = null;
// try
// {
// DoubleWallConnectorId = fabricationConnectorInfo.DoubleWallConnectorId;
// IsDoubleWallConnectorLocked = fabricationConnectorInfo.IsDoubleWallConnectorLocked;
// }
// catch (Exception e)
// {
// //TODO: no things
// }
// return new Dictionary<string, object?>
// {
// {"BodyConnectorId", fabricationConnectorInfo.BodyConnectorId},
// {"DoubleWallConnectorId",DoubleWallConnectorId },
// {"FabricationIndex", fabricationConnectorInfo.FabricationIndex},
// {"IsBodyConnectorLocked", fabricationConnectorInfo.IsBodyConnectorLocked},
// {"IsDoubleWallConnectorLocked",IsDoubleWallConnectorLocked },
// {"HasDoubleWallConnector", fabricationConnectorInfo.HasDoubleWallConnector()},
// {"IsValid", fabricationConnectorInfo.IsValid()},
// };
// }
}
15 changes: 9 additions & 6 deletions OpenMEP/ConnectorManager/ConnectorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private ConnectorManager()
/// return connector manager of element
/// </summary>
/// <param name="element">element</param>
/// <returns name="ConnectorManager">ConnectorManager</returns>
/// <returns name="ConnectorManager">Autodesk.Revit.DB.ConnectorManager</returns>
public static Autodesk.Revit.DB.ConnectorManager? GetConnectorManager( Revit.Elements.Element? element)
{
Autodesk.Revit.DB.Element? internalElement = element?.InternalElement;
Expand All @@ -32,6 +32,10 @@ private ConnectorManager()
{
return mepCurve.ConnectorManager;
}
if(internalElement is Autodesk.Revit.DB.FabricationPart fabricationPart)
{
return fabricationPart.ConnectorManager;
}

return null;
}
Expand Down Expand Up @@ -71,15 +75,14 @@ public static Revit.Elements.Element Owner( Autodesk.Revit.DB.ConnectorManager c
/// </summary>
/// <param name="connectorManager">connector manager</param>
/// <returns name="connectors">a collections of connector manager</returns>
public static List<Autodesk.Revit.DB.Connector> Connectors( Autodesk.Revit.DB.ConnectorManager? connectorManager)
public static List<Autodesk.Revit.DB.Connector?> Connectors( Autodesk.Revit.DB.ConnectorManager? connectorManager)
{
List<Autodesk.Revit.DB.Connector> connectors = new List<Autodesk.Revit.DB.Connector>();
ConnectorSet connectorSet = connectorManager.Connectors;
foreach (Autodesk.Revit.DB.Connector connector in connectorSet)
List<Autodesk.Revit.DB.Connector?> connectors = new List<Autodesk.Revit.DB.Connector?>();
ConnectorSet? connectorSet = connectorManager?.Connectors;
foreach (Autodesk.Revit.DB.Connector connector in connectorSet!)
{
connectors.Add(connector);
}

return connectors;
}

Expand Down
2 changes: 2 additions & 0 deletions OpenMEP/Element/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Autodesk.Revit.DB;
using Dynamo.Graph.Nodes;
using OpenMEP.Helpers;
using Revit.Elements;
using Revit.GeometryConversion;
using Point = Autodesk.DesignScript.Geometry.Point;

Expand All @@ -20,6 +21,7 @@ private Element()
/// <returns></returns>
public static Point? LocationCenter(Revit.Elements.Element? element)
{

if(element == null)
throw new ArgumentNullException(nameof(element));
if (element.InternalElement.Location is LocationPoint)
Expand Down
10 changes: 10 additions & 0 deletions OpenMEP/Element/FabricationPart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace OpenMEP.Element;

public class FabricationPart
{
private FabricationPart()
{

}

}
2 changes: 1 addition & 1 deletion docs/OpenMEPPage/connectormanager/connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -587,4 +587,4 @@
/// <returns name="ZXPlane">Plane(Blue-Red color)</returns>
```

![](dyn/pic/Connector.Display.png)
![](dyn/pic/Connector.Display.gif)
Loading

0 comments on commit 58f2bfc

Please sign in to comment.