Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Mar 2, 2023
2 parents 2f9654c + 89ad23e commit 8bb0b04
Show file tree
Hide file tree
Showing 7 changed files with 719 additions and 3 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.

35 changes: 34 additions & 1 deletion OpenMEP/Element/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ private Element()
LocationPoint? lc = element.InternalElement.Location as LocationPoint;
return lc?.Point.ToPoint();
}

if (element.InternalElement.Location is LocationCurve)
{
LocationCurve? lc = element.InternalElement.Location as LocationCurve;
Expand Down Expand Up @@ -129,6 +128,40 @@ private Element()
return doc.GetElement(levelId) as Autodesk.Revit.DB.Level;
}

/// <summary>
/// The system of the MEP element belong to.
/// </summary>
/// <param name="element">the element to get system</param>
/// <returns name="system">mep system of element</returns>
public static global::Revit.Elements.Element? System(global::Revit.Elements.Element element)
{
List<Connector?> connectors = ConnectorManager.Connector.GetConnectors(element);
if (connectors == null) throw new ArgumentNullException(nameof(element));
return connectors.Select(x => x!.MEPSystem.ToDynamoType()).FirstOrDefault();
}

/// <summary>
/// return type of MEP System
/// </summary>
/// <param name="element">the element of mep</param>
/// <returns name="systemType">system type of element from connector</returns>
public static global::Revit.Elements.Element SystemType(global::Revit.Elements.Element element)
{
global::Revit.Elements.Element? system = System(element);
return system!.ElementType;
}

/// <summary>
/// Returns the MEP System Type from connectors of the element
/// </summary>
/// <param name="element">the element of mep</param>
/// <returns name="systemType">system type from connector of element</returns>
public static dynamic? ConnectorSystemType(global::Revit.Elements.Element element)
{
List<Connector?> connectors = ConnectorManager.Connector.GetConnectors(element);
dynamic? systemType = connectors.Select(x => ConnectorManager.Connector.SystemType(x)).FirstOrDefault();
return systemType;
}


}
2 changes: 1 addition & 1 deletion OpenMEP/Element/Pipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ Autodesk.DesignScript.Geometry.Point point
RoutingPreferenceRuleGroupType routingtype)
{
Autodesk.Revit.DB.Plumbing.Pipe? internalElement = pipe!.InternalElement as Autodesk.Revit.DB.Plumbing.Pipe;
PipeType? pipeType = internalElement?.PipeType;
Autodesk.Revit.DB.Plumbing.PipeType? pipeType = internalElement?.PipeType;
RoutingPreferenceManager? routePrefManager = pipeType?.RoutingPreferenceManager;
RoutingConditions rou = new RoutingConditions(RoutingPreferenceErrorLevel.None);
//rou.PreferredJunctionType = PreferredJunctionType.Tee;
Expand Down
48 changes: 48 additions & 0 deletions OpenMEP/Element/PipeType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using OpenMEP.Helpers;
using RevitServices.Persistence;

namespace OpenMEP.Element;

public class PipeType
{
private PipeType()
{

}

/// <summary>
/// get pipe type by name
/// </summary>
/// <param name="typeName">type name of pipe</param>
/// <returns></returns>
public static Revit.Elements.Element? GetPipeTypeByName(string typeName)
{
return GetAllPipeTypes().FirstOrDefault(x => x!.Name == typeName);
}

/// <summary>
/// return all pipe types of the current document
/// </summary>
/// <returns name="pipeTypes">All Pipe Types</returns>
public static List<Revit.Elements.Element?> GetAllPipeTypes()
{
// Get all the pipe types in the current document
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(doc);
Autodesk.Revit.DB.ElementClassFilter filter = new Autodesk.Revit.DB.ElementClassFilter(typeof(Autodesk.Revit.DB.Plumbing.PipeType));
Autodesk.Revit.DB.FilteredElementIterator iterator = collector.WherePasses(filter).GetElementIterator();
iterator.Reset();
List<Revit.Elements.Element?> pipeTypes = new List<Revit.Elements.Element?>();
while (iterator.MoveNext())
{
Autodesk.Revit.DB.Element element = iterator.Current!;
if (element is Autodesk.Revit.DB.Plumbing.PipeType pipeType)
{
pipeTypes.Add(pipeType.ToDynamoType());
}
}
return pipeTypes;
}


}
2 changes: 1 addition & 1 deletion OpenMEP/Element/PipingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private PipingSystem()
/// </summary>
/// <param name="toggle">flag true or false to fresh</param>
/// <returns name="pipeingSystemTypes">pipePingSystemTypes</returns>
public static IEnumerable<Revit.Elements.Element?> All(bool toggle)
public static IEnumerable<Revit.Elements.Element?> GetAllPipeSystemTypes(bool toggle)
{
// filter for all piping systems
Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
Expand Down
2 changes: 2 additions & 0 deletions docs/OpenMEPPage/element/duct.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

### Create By Two Point



### Create By Two Connector

### Create By Line
Expand Down
Loading

0 comments on commit 8bb0b04

Please sign in to comment.