Skip to content

Commit 8e3ec58

Browse files
committed
Merge branch 'dev' of https://github.com/chuongmep/OpenMEP into dev
2 parents a470415 + 3f09f2f commit 8e3ec58

File tree

3 files changed

+92
-6
lines changed

3 files changed

+92
-6
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using Autodesk.DesignScript.Runtime;
2+
using Autodesk.Revit.DB;
3+
using Dynamo.Graph.Nodes;
4+
using Revit.Elements;
5+
using Category = Revit.Elements.Category;
6+
7+
namespace OpenMEPRevit.Element;
8+
9+
[IsVisibleInDynamoLibrary(true)]
10+
public class ParameterFilterElement
11+
{
12+
private ParameterFilterElement()
13+
{
14+
}
15+
16+
public List<Category>? Categories(Revit.Elements.Element parameterElement)
17+
{
18+
List<Category> categories = new List<Category>();
19+
Autodesk.Revit.DB.ParameterFilterElement? parameterFilterElement = parameterElement.InternalElement as Autodesk.Revit.DB.ParameterFilterElement;
20+
ICollection<ElementId>? elementIds = parameterFilterElement?.GetCategories();
21+
if (elementIds == null)
22+
{
23+
return categories;
24+
}
25+
#if R20 || R21 || R22 || R23
26+
foreach (ElementId elementId in elementIds)
27+
{
28+
categories.Add(Category.ById(elementId.IntegerValue));
29+
}
30+
#else
31+
foreach (ElementId elementId in elementIds)
32+
{
33+
categories.Add(Category.ById(elementId.Value));
34+
}
35+
#endif
36+
return categories;
37+
}
38+
/// <summary>
39+
/// Return All Element Inside View Filter
40+
/// </summary>
41+
/// <param name="viewFilter"></param>
42+
/// <returns name="elements">elements get from view filter</returns>
43+
/// <example>
44+
/// ![](../OpenMEPPage/element/dyn/pic/View.GetAllElementByViewFilter.png)
45+
/// [View.GetAllElementByViewFilter.dyn](../OpenMEPPage/element/dyn/View.GetAllElementByViewFilter.dyn)
46+
/// </example>
47+
[NodeCategory("Action")]
48+
[NodeSearchTags("get element")]
49+
public static List<Revit.Elements.Element> GetAllElementByViewFilter(Revit.Elements.Element viewFilter)
50+
{
51+
Autodesk.Revit.DB.Document doc = viewFilter.InternalElement.Document;
52+
Autodesk.Revit.DB.ParameterFilterElement? parameterFilterElement = viewFilter.InternalElement as Autodesk.Revit.DB.ParameterFilterElement;
53+
if (parameterFilterElement == null)
54+
return new List<Revit.Elements.Element>();
55+
ElementFilter elementFilter = parameterFilterElement.GetElementFilter();
56+
ICollection<ElementId> cates = parameterFilterElement.GetCategories();
57+
IList<ElementFilter> eleFilters = new List<ElementFilter>();
58+
foreach (var cat in cates)
59+
{
60+
eleFilters.Add(new ElementCategoryFilter(cat));
61+
}
62+
var cateFilter = new LogicalOrFilter(eleFilters);
63+
if (elementFilter != null)
64+
{
65+
return new FilteredElementCollector(doc)
66+
.WhereElementIsNotElementType()
67+
.WhereElementIsViewIndependent()
68+
.WherePasses(cateFilter)
69+
.WherePasses(elementFilter)
70+
.ToElements().Select(x => x.ToDSType(true)).ToList();
71+
}
72+
return new FilteredElementCollector(doc)
73+
.WhereElementIsNotElementType()
74+
.WhereElementIsViewIndependent()
75+
.WherePasses(cateFilter)
76+
.ToElements().Select(x => x.ToDSType(true)).ToList();
77+
}
78+
}

OpenMEPRevit/Element/View.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ private View()
2424
public static List<Revit.Elements.Element> GetAllViewFilters(bool flag)
2525
{
2626
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
27-
List<ParameterFilterElement> parameterFilterElements = new FilteredElementCollector(doc)
28-
.OfClass(typeof(ParameterFilterElement))
29-
.OfType<ParameterFilterElement>()
27+
List<Autodesk.Revit.DB.ParameterFilterElement> parameterFilterElements = new FilteredElementCollector(doc)
28+
.OfClass(typeof(Autodesk.Revit.DB.ParameterFilterElement))
29+
.OfType<Autodesk.Revit.DB.ParameterFilterElement>()
3030
.OrderBy(x => x.Name)
3131
.ToList();
3232
if (parameterFilterElements.Count == 0)
@@ -43,12 +43,13 @@ private View()
4343
/// ![](../OpenMEPPage/element/dyn/pic/View.GetAllElementByViewFilter.png)
4444
/// [View.GetAllElementByViewFilter.dyn](../OpenMEPPage/element/dyn/View.GetAllElementByViewFilter.dyn)
4545
/// </example>
46+
[Obsolete("This method is obsolete, please use OpenMEPRevit.Element.ParameterFilterElement.GetAllElementByViewFilter instead.")]
4647
[NodeCategory("Action")]
4748
[NodeSearchTags("get element")]
4849
public static List<Revit.Elements.Element> GetAllElementByViewFilter(Revit.Elements.Element viewFilter)
4950
{
5051
Autodesk.Revit.DB.Document doc = DocumentManager.Instance.CurrentDBDocument;
51-
ParameterFilterElement? parameterFilterElement = viewFilter.InternalElement as ParameterFilterElement;
52+
Autodesk.Revit.DB.ParameterFilterElement? parameterFilterElement = viewFilter.InternalElement as Autodesk.Revit.DB.ParameterFilterElement;
5253
if (parameterFilterElement == null)
5354
return new List<Revit.Elements.Element>();
5455
ElementFilter elementFilter = parameterFilterElement.GetElementFilter();

OpenMEPRevit/OpenMEPRevit.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PlatformTarget>x64</PlatformTarget>
1313
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1414
<Configurations>Debug R23.1;Debug R24;Debug R20;Debug R21;Debug R22;Debug R23;</Configurations>
15-
<Configurations>$(Configurations);Release R25;Release R24.2;Release R24.1;Release R24;Release R23.1;Release R20;Release R21;Release R22;Release R23;</Configurations>
15+
<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>
1616
<NoWarn>CS1591;CS0168;CS8618;CS1591;CS0419;MSB3277</NoWarn>
1717
</PropertyGroup>
1818
<PropertyGroup Condition="$(Configuration.Contains('Debug R20'))">
@@ -57,6 +57,13 @@
5757
<DefineConstants>$(DefineConstants);R22</DefineConstants>
5858
</PropertyGroup>
5959
<PropertyGroup Condition="$(Configuration.Contains('Release R22'))">
60+
<DynamoVersion>2.12</DynamoVersion>
61+
<DynamoOutput>2.10</DynamoOutput>
62+
<RevitVersion>2022</RevitVersion>
63+
<TargetFramework>net48</TargetFramework>
64+
<DefineConstants>$(DefineConstants);R22</DefineConstants>
65+
</PropertyGroup>
66+
<PropertyGroup Condition="$(Configuration.Contains('Release R22.1'))">
6067
<DynamoVersion>2.12</DynamoVersion>
6168
<DynamoOutput>2.12</DynamoOutput>
6269
<RevitVersion>2022</RevitVersion>
@@ -125,7 +132,7 @@
125132
</PropertyGroup>
126133
<PropertyGroup Condition="$(Configuration.Contains('Release R25'))">
127134
<DynamoVersion>3.0</DynamoVersion>
128-
<DynamoOutput>3.0</DynamoOutput>
135+
<DynamoOutput>3.2</DynamoOutput>
129136
<RevitVersion>2025</RevitVersion>
130137
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
131138
<TargetFramework>net8.0-windows</TargetFramework>

0 commit comments

Comments
 (0)