Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/chuongmep/OpenMEP into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Nov 20, 2024
2 parents a470415 + 3f09f2f commit 8e3ec58
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 6 deletions.
78 changes: 78 additions & 0 deletions OpenMEPRevit/Element/ParameterFilterElement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Autodesk.DesignScript.Runtime;
using Autodesk.Revit.DB;
using Dynamo.Graph.Nodes;
using Revit.Elements;
using Category = Revit.Elements.Category;

namespace OpenMEPRevit.Element;

[IsVisibleInDynamoLibrary(true)]
public class ParameterFilterElement
{
private ParameterFilterElement()
{
}

public List<Category>? Categories(Revit.Elements.Element parameterElement)
{
List<Category> categories = new List<Category>();
Autodesk.Revit.DB.ParameterFilterElement? parameterFilterElement = parameterElement.InternalElement as Autodesk.Revit.DB.ParameterFilterElement;
ICollection<ElementId>? elementIds = parameterFilterElement?.GetCategories();
if (elementIds == null)
{
return categories;
}
#if R20 || R21 || R22 || R23
foreach (ElementId elementId in elementIds)
{
categories.Add(Category.ById(elementId.IntegerValue));
}
#else
foreach (ElementId elementId in elementIds)
{
categories.Add(Category.ById(elementId.Value));
}
#endif
return categories;
}
/// <summary>
/// Return All Element Inside View Filter
/// </summary>
/// <param name="viewFilter"></param>
/// <returns name="elements">elements get from view filter</returns>
/// <example>
/// ![](../OpenMEPPage/element/dyn/pic/View.GetAllElementByViewFilter.png)
/// [View.GetAllElementByViewFilter.dyn](../OpenMEPPage/element/dyn/View.GetAllElementByViewFilter.dyn)
/// </example>
[NodeCategory("Action")]
[NodeSearchTags("get element")]
public static List<Revit.Elements.Element> GetAllElementByViewFilter(Revit.Elements.Element viewFilter)
{
Autodesk.Revit.DB.Document doc = viewFilter.InternalElement.Document;
Autodesk.Revit.DB.ParameterFilterElement? parameterFilterElement = viewFilter.InternalElement as Autodesk.Revit.DB.ParameterFilterElement;
if (parameterFilterElement == null)
return new List<Revit.Elements.Element>();
ElementFilter elementFilter = parameterFilterElement.GetElementFilter();
ICollection<ElementId> cates = parameterFilterElement.GetCategories();
IList<ElementFilter> eleFilters = new List<ElementFilter>();
foreach (var cat in cates)
{
eleFilters.Add(new ElementCategoryFilter(cat));
}
var cateFilter = new LogicalOrFilter(eleFilters);
if (elementFilter != null)
{
return new FilteredElementCollector(doc)
.WhereElementIsNotElementType()
.WhereElementIsViewIndependent()
.WherePasses(cateFilter)
.WherePasses(elementFilter)
.ToElements().Select(x => x.ToDSType(true)).ToList();
}
return new FilteredElementCollector(doc)
.WhereElementIsNotElementType()
.WhereElementIsViewIndependent()
.WherePasses(cateFilter)
.ToElements().Select(x => x.ToDSType(true)).ToList();
}
}
9 changes: 5 additions & 4 deletions OpenMEPRevit/Element/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ private View()
public static List<Revit.Elements.Element> GetAllViewFilters(bool flag)
{
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
List<ParameterFilterElement> parameterFilterElements = new FilteredElementCollector(doc)
.OfClass(typeof(ParameterFilterElement))
.OfType<ParameterFilterElement>()
List<Autodesk.Revit.DB.ParameterFilterElement> parameterFilterElements = new FilteredElementCollector(doc)
.OfClass(typeof(Autodesk.Revit.DB.ParameterFilterElement))
.OfType<Autodesk.Revit.DB.ParameterFilterElement>()
.OrderBy(x => x.Name)
.ToList();
if (parameterFilterElements.Count == 0)
Expand All @@ -43,12 +43,13 @@ private View()
/// ![](../OpenMEPPage/element/dyn/pic/View.GetAllElementByViewFilter.png)
/// [View.GetAllElementByViewFilter.dyn](../OpenMEPPage/element/dyn/View.GetAllElementByViewFilter.dyn)
/// </example>
[Obsolete("This method is obsolete, please use OpenMEPRevit.Element.ParameterFilterElement.GetAllElementByViewFilter instead.")]
[NodeCategory("Action")]
[NodeSearchTags("get element")]
public static List<Revit.Elements.Element> GetAllElementByViewFilter(Revit.Elements.Element viewFilter)
{
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
ParameterFilterElement? parameterFilterElement = viewFilter.InternalElement as ParameterFilterElement;
Autodesk.Revit.DB.ParameterFilterElement? parameterFilterElement = viewFilter.InternalElement as Autodesk.Revit.DB.ParameterFilterElement;
if (parameterFilterElement == null)
return new List<Revit.Elements.Element>();
ElementFilter elementFilter = parameterFilterElement.GetElementFilter();
Expand Down
11 changes: 9 additions & 2 deletions OpenMEPRevit/OpenMEPRevit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PlatformTarget>x64</PlatformTarget>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Configurations>Debug R23.1;Debug R24;Debug R20;Debug R21;Debug R22;Debug R23;</Configurations>
<Configurations>$(Configurations);Release R25;Release R24.2;Release R24.1;Release R24;Release R23.1;Release R20;Release R21;Release R22;Release R23;</Configurations>
<Configurations>$(Configurations);Release R25;Release R24.2;Release R24.1;Release R24;Release R23.1;Release R20;Release R21;Release R22;Release R22.1;Release R23;</Configurations>
<NoWarn>CS1591;CS0168;CS8618;CS1591;CS0419;MSB3277</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug R20'))">
Expand Down Expand Up @@ -57,6 +57,13 @@
<DefineConstants>$(DefineConstants);R22</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release R22'))">
<DynamoVersion>2.12</DynamoVersion>
<DynamoOutput>2.10</DynamoOutput>
<RevitVersion>2022</RevitVersion>
<TargetFramework>net48</TargetFramework>
<DefineConstants>$(DefineConstants);R22</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release R22.1'))">
<DynamoVersion>2.12</DynamoVersion>
<DynamoOutput>2.12</DynamoOutput>
<RevitVersion>2022</RevitVersion>
Expand Down Expand Up @@ -125,7 +132,7 @@
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Release R25'))">
<DynamoVersion>3.0</DynamoVersion>
<DynamoOutput>3.0</DynamoOutput>
<DynamoOutput>3.2</DynamoOutput>
<RevitVersion>2025</RevitVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFramework>net8.0-windows</TargetFramework>
Expand Down

0 comments on commit 8e3ec58

Please sign in to comment.