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 23, 2023
2 parents df79638 + b445f1f commit 0e68d69
Show file tree
Hide file tree
Showing 188 changed files with 13,784 additions and 12 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/Deploy_Page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: deploy-book

# Only run this when the master branch changes
on:
push:
branches:
- docs
# If your git repository has the Jupyter Book within some-subfolder next to
# unrelated files, you can make this run only if a file within that specific
# folder has been modified.
#
# paths:
# - some-subfolder/**

# This job installs dependencies, builds the book, and pushes it to `gh-pages`
jobs:
deploy-book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Install dependencies
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
pip install -r ./docs/OpenMEPPage/requirements.txt
# Build the book
- name: Build the book
run: |
jupyter-book build ./docs/OpenMEPPage
# Push the book's HTML to github-pages
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/OpenMEPPage/_build/html
3 changes: 2 additions & 1 deletion .github/workflows/Workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Workflow
on:
push:
branches:
- '**'
- dev
- master
pull_request:
branches:
- '!master'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,4 @@ MigrationBackup/
# ignore output msi
output/
wix/
_build
13 changes: 13 additions & 0 deletions OpenMEP.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeployInstaller", "DeployIn
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "build\_build.csproj", "{47C2ECE9-1C28-4E63-A376-A2DE72DF37B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenMEPTest", "OpenMEPTest\OpenMEPTest.csproj", "{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug R20|Any CPU = Debug R20|Any CPU
Expand Down Expand Up @@ -74,5 +76,16 @@ Global
{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}.Release R23.1|Any CPU.ActiveCfg = Release|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Debug R20|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Debug R21|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Debug R22|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Debug R23|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Debug R23.1|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Release R20|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Release R21|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Release R22|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Release R23|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Release R23.1|Any CPU.ActiveCfg = Debug|Any CPU
{C4A7A7CC-2B34-4359-B16E-F8F2082CB840}.Installer|Any CPU.ActiveCfg = Debug|Any CPU
EndGlobalSection
EndGlobal
43 changes: 43 additions & 0 deletions OpenMEP/Application/Dynamo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Reflection;
using Dynamo.Applications;

namespace OpenMEP.Application;

public class Dynamo
{
private Dynamo()
{
}

/// <summary>
/// return current version of dynamo
/// </summary>
/// <returns name="version">version</returns>
public static string Version()
{
Assembly assembly = Assembly.Load("DynamoCore");
Version version = assembly.GetName().Version;
return version.ToString();
}

#if R20
#else
/// <summary>
/// return current file name of script opening
/// </summary>
/// <returns></returns>
public static string CurrentFileName()
{
try
{
string fileName = DynamoRevit.RevitDynamoModel.CurrentWorkspace.FileName;
if (string.IsNullOrEmpty(fileName)) return "Home";
return fileName;
}
catch (Exception e)
{
return string.Empty;
}
}
#endif
}
47 changes: 47 additions & 0 deletions OpenMEP/Application/OpenMEP.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.Win32;

namespace OpenMEP.Application;

public class OpenMEP
{
private OpenMEP()
{

}
/// <summary>
/// Return Current Version Installed In Computer
/// </summary>
public static string? Version
{
get
{
string appName = "OpenMEP";
string? displayName;
string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryKey)!;
foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName)))
{
displayName = subkey!.GetValue("DisplayName") as string;
if (displayName != null && displayName.Contains(appName))
{
return (subkey.GetValue("DisplayVersion") as string)!;
}
}
key.Close();

registryKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryKey)!;
foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName)))
{
displayName = subkey!.GetValue("DisplayName") as string;
if (displayName != null && displayName.Contains(appName))
{
return subkey.GetValue("DisplayVersion") as string;
}
}
key.Close();
return string.Empty;
}

}
}
20 changes: 20 additions & 0 deletions OpenMEP/Application/Revit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using RevitServices.Persistence;

namespace OpenMEP.Application;

public class Revit
{
private Revit()
{

}

/// <summary>
/// return version number of revit
/// </summary>
/// <returns name="string">version</returns>
public static string Version()
{
return DocumentManager.Instance.CurrentUIDocument.Application.Application.VersionNumber;
}
}
34 changes: 34 additions & 0 deletions OpenMEP/Application/Windows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Autodesk.DesignScript.Runtime;

namespace OpenMEP.Application;

public class Windows
{
private Windows()
{

}

/// <summary>
/// return version number of windows
/// </summary>
/// <returns></returns>
[MultiReturn("build", "major", "minor", "revision", "version")]
public static Dictionary<string, object?> Version()
{
// Get version System
int build = System.Environment.OSVersion.Version.Build;
int major = System.Environment.OSVersion.Version.Major;
int minor = System.Environment.OSVersion.Version.Minor;
int revision = System.Environment.OSVersion.Version.Revision;
string version = System.Environment.OSVersion.Version.ToString();
return new Dictionary<string, object?>()
{
{"build", build},
{"major", major},
{"minor", minor},
{"revision", revision},
{"version", version}
};
}
}
5 changes: 1 addition & 4 deletions OpenMEP/Element/MEPCurve.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System.Collections;
using System.Diagnostics;
using Autodesk.DesignScript.Runtime;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Mechanical;
using Autodesk.Revit.DB.Plumbing;
using Dynamo.Graph.Nodes;
using GShark.Geometry;
using OpenMEP.Helpers;
using Revit.GeometryConversion;
using RevitServices.Persistence;
using RevitServices.Transactions;
using Line = Autodesk.Revit.DB.Line;

Expand Down Expand Up @@ -390,7 +387,7 @@ private static void AdjustMepCurve(Autodesk.Revit.DB.Element mepCurve, XYZ p1, X
}

/// <summary>
/// Return four points closest inside four mep curves
/// Return four connector closest inside four mep curves
/// </summary>
/// <param name="mepCurve1">the first mepCurve</param>
/// <param name="mepCurve2">the second mepCurve</param>
Expand Down
43 changes: 42 additions & 1 deletion OpenMEP/Geometry/Point.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,50 @@
namespace OpenMEP.Geometry;
using Autodesk.Revit.DB;

namespace OpenMEP.Geometry;

public class Point
{
private Point()
{

}

/// <summary>
/// Project a point onto a plane
/// </summary>
/// <param name="point">point need to project</param>
/// <param name="planeNormal">vector normal of plane</param>
/// <returns name="point">new point projected on plane</returns>
public static Autodesk.DesignScript.Geometry.Point ProjectOntoPlane(
Autodesk.DesignScript.Geometry.Point point,
Autodesk.DesignScript.Geometry.Vector planeNormal )
{
double a = planeNormal.X;
double b = planeNormal.Y;
double c = planeNormal.Z;

double dx = ( b * b + c * c ) * point.X - ( a * b ) * point.Y - ( a * c ) * point.Z;
double dy = -( b * a ) * point.X + ( a * a + c * c ) * point.Y - ( b * c ) * point.Z;
double dz = -( c * a ) * point.X - ( c * b ) * point.Y + ( a * a + b * b ) * point.Z;
return Autodesk.DesignScript.Geometry.Point.ByCoordinates( dx, dy, dz );
}

/// <summary>
/// Get the centroid of a list of points
/// </summary>
/// <param name="points">list of points</param>
/// <returns name="point">centroid</returns>
public static Autodesk.DesignScript.Geometry.Point Centroid( List<Autodesk.DesignScript.Geometry.Point> points )
{
double x = 0;
double y = 0;
double z = 0;
foreach ( Autodesk.DesignScript.Geometry.Point point in points )
{
x += point.X;
y += point.Y;
z += point.Z;
}
return Autodesk.DesignScript.Geometry.Point.ByCoordinates( x / points.Count, y / points.Count, z / points.Count );
}
}
5 changes: 0 additions & 5 deletions OpenMEP/OpenMEP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@
<DependentUpon>OpenMEPImages.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Application\Dynamo" />
<Folder Include="Application\Revit" />
<Folder Include="Application\Windows" />
</ItemGroup>
<Target Name="CopyFiles" AfterTargets="CoreBuild">
<ItemGroup>
<AssemblyFiles Include="$(TargetDir)*.*" />
Expand Down
72 changes: 72 additions & 0 deletions OpenMEPTest/ConnectorManagerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Linq;
using Autodesk.Revit.DB;
using NUnit.Framework;
using RTF.Applications;
using RTF.Framework;

namespace OpenMEPTest;

[TestFixture]
public class ConnectorManagerTest
{
[SetUp]
public void SetUp()
{
var doc = RevitTestExecutive.CommandData.Application.ActiveUIDocument.Document;
Assert.IsNotNull(doc);
}

[Test]
[TestModel("Resources/bricks.rfa")]
public void ModelHasTheCorrectNumberOfBricks()
{
var doc = RevitTestExecutive.CommandData.Application.ActiveUIDocument.Document;

var fec = new FilteredElementCollector(doc);
fec.OfClass(typeof(FamilyInstance));

var bricks = fec.ToElements()
.Cast<FamilyInstance>()
.Where(fi => fi.Symbol.Family.Name == "brick");

Assert.AreEqual(bricks.Count(), 4);
}

/// <summary>
/// This is the Hello World of Revit testing. Here we
/// simply call the Revit API to create a new ReferencePoint
/// in the default empty.rfa file.
/// </summary>
[Test]
public void CanCreateAReferencePoint()
{
var doc = RevitTestExecutive.CommandData.Application.ActiveUIDocument.Document;

using (var t = new Transaction(doc))
{
if (t.Start("Test one.") == TransactionStatus.Started)
{
//create a reference point
var pt = doc.FamilyCreate.NewReferencePoint(new XYZ(5, 5, 5));

if (t.Commit() != TransactionStatus.Committed)
{
t.RollBack();
}
}
else
{
throw new Exception("Transaction could not be started.");
}
}
//verify that the point was created
var collector = new FilteredElementCollector(doc);
collector.OfClass(typeof (ReferencePoint));
Assert.AreEqual(1, collector.ToElements().Count);
}


}


Loading

0 comments on commit 0e68d69

Please sign in to comment.