Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/chuongmep/OpenMEP
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Feb 20, 2023
2 parents 7d75247 + dc60e30 commit cc83dd8
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 19 deletions.
12 changes: 12 additions & 0 deletions OpenMEP.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ Global
Debug R21|Any CPU = Debug R21|Any CPU
Debug R22|Any CPU = Debug R22|Any CPU
Debug R23|Any CPU = Debug R23|Any CPU
Debug R23.1|Any CPU = Debug R23.1|Any CPU
Release R20|Any CPU = Release R20|Any CPU
Release R21|Any CPU = Release R21|Any CPU
Release R22|Any CPU = Release R22|Any CPU
Release R23|Any CPU = Release R23|Any CPU
Release R23.1|Any CPU = Release R23.1|Any CPU
Installer|Any CPU = Installer|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
Expand All @@ -45,6 +47,10 @@ Global
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Debug R20|Any CPU.Build.0 = Debug R20|Any CPU
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Release R20|Any CPU.ActiveCfg = Release R20|Any CPU
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Release R20|Any CPU.Build.0 = Release R20|Any CPU
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Debug R23.1|Any CPU.ActiveCfg = Debug R23.1|Any CPU
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Debug R23.1|Any CPU.Build.0 = Debug R23.1|Any CPU
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Release R23.1|Any CPU.ActiveCfg = Release R23.1|Any CPU
{A7FE0286-8CEA-4C63-9603-22D79E98EAB1}.Release R23.1|Any CPU.Build.0 = Release R23.1|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Debug R21|Any CPU.ActiveCfg = Debug|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Debug R22|Any CPU.ActiveCfg = Debug|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Debug R22|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -56,6 +62,9 @@ Global
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Installer|Any CPU.Build.0 = Release|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Debug R20|Any CPU.ActiveCfg = Debug|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Release R20|Any CPU.ActiveCfg = Release|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Debug R23.1|Any CPU.ActiveCfg = Debug|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Debug R23.1|Any CPU.Build.0 = Debug|Any CPU
{C7835EFE-E1C7-48B2-90D0-E943D43A905D}.Release R23.1|Any CPU.ActiveCfg = Release|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Debug R21|Any CPU.ActiveCfg = Debug|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Debug R22|Any CPU.ActiveCfg = Debug|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Debug R22|Any CPU.Build.0 = Debug|Any CPU
Expand All @@ -66,5 +75,8 @@ Global
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Installer|Any CPU.ActiveCfg = Release|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Debug R20|Any CPU.ActiveCfg = Debug|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Release R20|Any CPU.ActiveCfg = Release|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Debug R23.1|Any CPU.ActiveCfg = Debug|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Debug R23.1|Any CPU.Build.0 = Debug|Any CPU
{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}.Release R23.1|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal
25 changes: 19 additions & 6 deletions OpenMEP/Element/CableTray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ private CableTray()
{
}

#if !R20
/// <summary>
/// <summary>
/// Creates a new instance of cable tray by start point and end point
/// </summary>
/// <param name="cableTrayType">The cable tray type. This must be a cable tray type accepted by isValidCableTrayType(). If the input cable tray type is InvalidElementId, the default cable tray type from the document will be used.</param>
Expand All @@ -34,18 +33,26 @@ private CableTray()
Autodesk.Revit.DB.Electrical.CableTray familyInstance = Autodesk.Revit.DB.Electrical.CableTray.Create(doc,
new ElementId(cableTrayType.Id), startPoint.ToRevitType(true), endPoint.ToRevitType(true),
new ElementId(level.Id));
Autodesk.Revit.DB.ForgeTypeId unitTypeId =
#if R20
DisplayUnitType displayUnitType =
familyInstance.Document.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits;
double realWidth = UnitUtils.ConvertFromInternalUnits(width, displayUnitType);
double realHeight = UnitUtils.ConvertFromInternalUnits(height, displayUnitType);
#else
Autodesk.Revit.DB.ForgeTypeId unitTypeId =
familyInstance.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId();
double realWidth = UnitUtils.ConvertFromInternalUnits(width, unitTypeId);
double realHeight = UnitUtils.ConvertFromInternalUnits(height, unitTypeId);
#endif

familyInstance.get_Parameter(BuiltInParameter.RBS_CABLETRAY_WIDTH_PARAM)
.SetValueString(realWidth.ToString(CultureInfo.InvariantCulture));
familyInstance.get_Parameter(BuiltInParameter.RBS_CABLETRAY_HEIGHT_PARAM)
.SetValueString(realHeight.ToString(CultureInfo.InvariantCulture));
TransactionManager.Instance.TransactionTaskDone();
return familyInstance.ToDynamoType();
}

/// <summary>
/// create new cable tray by line
/// </summary>
Expand All @@ -65,17 +72,23 @@ private CableTray()
Autodesk.Revit.DB.Electrical.CableTray familyInstance = Autodesk.Revit.DB.Electrical.CableTray.Create(doc,
new ElementId(cableTrayType.Id), line.StartPoint.ToXyz(), line.EndPoint.ToXyz(),
new ElementId(level.Id));
#if R20
DisplayUnitType displayUnitType =
familyInstance.Document.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits;
double realWidth = UnitUtils.ConvertFromInternalUnits(width, displayUnitType);
double realHeight = UnitUtils.ConvertFromInternalUnits(height, displayUnitType);
#else
Autodesk.Revit.DB.ForgeTypeId unitTypeId =
familyInstance.Document.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId();
double realWidth = UnitUtils.ConvertFromInternalUnits(width, unitTypeId);
double realHeight = UnitUtils.ConvertFromInternalUnits(height, unitTypeId);
#endif

familyInstance.get_Parameter(BuiltInParameter.RBS_CABLETRAY_WIDTH_PARAM)
.SetValueString(realWidth.ToString(CultureInfo.InvariantCulture));
familyInstance.get_Parameter(BuiltInParameter.RBS_CABLETRAY_HEIGHT_PARAM)
.SetValueString(realHeight.ToString(CultureInfo.InvariantCulture));
TransactionManager.Instance.TransactionTaskDone();
return familyInstance.ToDynamoType();
}
#endif

}
84 changes: 83 additions & 1 deletion OpenMEP/Element/Conduit.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,91 @@
namespace OpenMEP.Element;
using Autodesk.Revit.DB;
using Dynamo.Graph.Nodes;
using OpenMEP.Helpers;
using RevitServices.Persistence;
using RevitServices.Transactions;

namespace OpenMEP.Element;

public class Conduit
{
private Conduit()
{

}

/// <summary>Creates a new instance of conduit.</summary>
/// <remarks>This method will regenerate the document.</remarks>
/// <param name="conduitType">
/// The conduit type. This must be a conduit type accepted by isValidConduitType().
/// If the input conduit type is InvalidElementId, the default conduit type from the document will be used.
/// </param>
/// <param name="startPoint">The start point of the conduit location line.</param>
/// <param name="endPoint">The end point of the conduit location line.</param>
/// <param name="level">
/// The element of the level which this conduit based.
/// If the input level id is invalidElementId = -1, the nearest level will be used.
/// </param>
/// <returns>The newly created conduit.</returns>
/// <exception cref="T:Autodesk.Revit.Exceptions.ArgumentException">
/// This conduit type is invalid.
/// -or-
/// This level id is invalid.
/// -or-
/// The points of startPoint and endPoint are too close: for MEPCurve, the minimum length is 1/10 inch.
/// </exception>
/// <exception cref="T:Autodesk.Revit.Exceptions.ArgumentNullException">
/// A non-optional argument was null
/// </exception>
/// <exception cref="T:Autodesk.Revit.Exceptions.DisabledDisciplineException">
/// None of the following disciplines is enabled: Mechanical Electrical Piping.
/// </exception>
/// <exception cref="T:Autodesk.Revit.Exceptions.InvalidOperationException">
/// The document is in failure mode: an operation has failed,
/// and Revit requires the user to either cancel the operation
/// or fix the problem (usually by deleting certain elements).
/// </exception>
/// <exception cref="T:Autodesk.Revit.Exceptions.ModificationForbiddenException">
/// The document is in failure mode: an operation has failed,
/// and Revit requires the user to either cancel the operation
/// or fix the problem (usually by deleting certain elements).
/// -or-
/// The document is being loaded, or is in the midst of another
/// sensitive process.
/// </exception>
/// <exception cref="T:Autodesk.Revit.Exceptions.ModificationOutsideTransactionException">
/// The document has no open transaction.
/// </exception>
[NodeCategory("Create")]
public static Revit.Elements.Element? Create(Revit.Elements.Element conduitType,Autodesk.DesignScript.Geometry.Point startPoint,Autodesk.DesignScript.Geometry.Point endPoint,Revit.Elements.Element level)
{
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
TransactionManager.Instance.ForceCloseTransaction();
TransactionManager.Instance.EnsureInTransaction(doc);
Autodesk.Revit.DB.Electrical.Conduit conduit = Autodesk.Revit.DB.Electrical.Conduit.Create(doc, new ElementId(conduitType.Id), startPoint.ToRevitType(),
endPoint.ToRevitType(), new ElementId(level.Id));
TransactionManager.Instance.TransactionTaskDone();
return conduit.ToDynamoType();
}

/// <summary>
/// Create a conduit by line
/// </summary>
/// <param name="conduitType">
/// The conduit type. This must be a conduit type accepted by isValidConduitType().
/// If the input conduit type is InvalidElementId, the default conduit type from the document will be used.
/// </param>
/// <param name="line">the line define to draw conduit from start point to end point</param>
/// <param name="level">the element of level</param>
///<returns name="conduit">new conduit</returns>
[NodeCategory("Create")]
public static Revit.Elements.Element? Create(Revit.Elements.Element conduitType,Autodesk.DesignScript.Geometry.Line line,Revit.Elements.Element level)
{
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
TransactionManager.Instance.ForceCloseTransaction();
TransactionManager.Instance.EnsureInTransaction(doc);
Autodesk.Revit.DB.Electrical.Conduit conduit = Autodesk.Revit.DB.Electrical.Conduit.Create(doc, new ElementId(conduitType.Id), line.StartPoint.ToRevitType(),
line.EndPoint.ToRevitType(), new ElementId(level.Id));
TransactionManager.Instance.TransactionTaskDone();
return conduit.ToDynamoType();
}
}
1 change: 0 additions & 1 deletion OpenMEP/Element/DuctLining.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ public class DuctLining
{
private DuctLining()
{

}
}
18 changes: 16 additions & 2 deletions OpenMEP/OpenMEP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<PlatformTarget>x64</PlatformTarget>
<AssemblyVersion>1.0.0.*</AssemblyVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Configurations>Debug R20;Debug R21;Debug R22;Debug R23</Configurations>
<Configurations>$(Configurations);Release R20;Release R21;Release R22;Release R23</Configurations>
<Configurations>Debug R20;Debug R21;Debug R22;Debug R23;Debug R23.1</Configurations>
<Configurations>$(Configurations);Release R20;Release R21;Release R22;Release R23;Release R23.1</Configurations>
<NoWarn>CS1591;CS0168;CS8618;CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug R20'))">
Expand Down Expand Up @@ -59,6 +59,14 @@
<DefineConstants>$(DefineConstants);R22</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug R23'))">
<DynamoVersion>2.12</DynamoVersion>
<DynamoOutput>2.13</DynamoOutput>
<RevitVersion>2023</RevitVersion>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DefineConstants>$(DefineConstants);R23</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug R23.1'))">
<DynamoVersion>2.12</DynamoVersion>
<DynamoOutput>2.16</DynamoOutput>
<RevitVersion>2023</RevitVersion>
Expand All @@ -67,6 +75,12 @@
<DefineConstants>$(DefineConstants);R23</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release R23'))">
<DynamoVersion>2.12</DynamoVersion>
<DynamoOutput>2.13</DynamoOutput>
<RevitVersion>2023</RevitVersion>
<DefineConstants>$(DefineConstants);R23</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release R23.1'))">
<DynamoVersion>2.12</DynamoVersion>
<DynamoOutput>2.16</DynamoOutput>
<RevitVersion>2023</RevitVersion>
Expand Down
20 changes: 20 additions & 0 deletions OpenMEP/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"profiles": {
"Revit2020": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Revit 2020\\Revit.exe"
},
"Revit2021": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Revit 2021\\Revit.exe"
},
"Revit2022": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Revit 2022\\Revit.exe"
},
"Revit2023": {
"commandName": "Executable",
"executablePath": "C:\\Program Files\\Autodesk\\Revit 2023\\Revit.exe"
}
}
}
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ right components into your design.This library includes a wide range of mechanic
including pipes, fittings, valves, ducts, electrical equipment, and more fully automate your design process in design,
maintenance, calculation and analysis,...

We believe that the MEP Package will be a valuable asset to construction professionals looking to streamline the MEP
![](docs/img/OpenMEPPackage.png)

I believe that the MEP Package will be a valuable asset to construction professionals looking to streamline the MEP
design process and ensure that their projects are completed on time and within budget.

# Installation
Expand All @@ -35,13 +37,13 @@ Read more about [Installation](https://github.com/chuongmep/OpenMEP/wiki/How-To-

# Documentation (TODO)

- [How to Install OpenMEP Package](https://github.com/chuongmep/OpenMEP/wiki/How-To-Install-OpenMEP-Package)
- How to Use OpenMEP Package
- How to Contribute OpenMEP Package
- How to Report Bug
- How to Update OpenMEP Package
- How to Uninstall OpenMEP Package
- How to write python script with OpenMEP Package
- [How To Install OpenMEP Package](https://github.com/chuongmep/OpenMEP/wiki/How-To-Install-OpenMEP-Package)
- How To Uninstall OpenMEP Package
- How To Update OpenMEP Package
- How To Use OpenMEP Package
- How To Report Bug
- How To Contribute OpenMEP Package
- How To Write Python Script With OpenMEP Package

# Features

Expand Down
Binary file added docs/img/OpenMEPPackage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/pkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"contains_binaries": true,
"node_libraries": [
"OpenMEP, Version=1.0.0.*, Culture=neutral, PublicKeyToken=null",
"OpenMEP.customization, Version=1.0.0.*, Culture=neutral, PublicKeyToken=null"
"OpenMEP.customization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
]
}

0 comments on commit cc83dd8

Please sign in to comment.