Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.16 #984

Merged
merged 2 commits into from
Aug 4, 2023
Merged

1.16 #984

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified docs/static/images/guides/revit-walls-profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/static/images/guides/revit-walls-profilelines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions src/RhinoInside.Revit.External/DB/CompoundElementFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public static ElementFilter ElementKindFilter(ElementKind kind, bool? elementTyp
(kind.HasFlag(ElementKind.Direct) ? ElementKind.None : ElementKind.Direct);
}

if (kind == ElementKind.None) return Empty;

if (kind.HasFlag(ElementKind.Component) != kind.HasFlag(ElementKind.System))
{
if (elementType != true)
Expand All @@ -187,10 +189,17 @@ public static ElementFilter ElementKindFilter(ElementKind kind, bool? elementTyp
filters.Add(new ElementClassFilter(typeof(DirectShapeType), kind.HasFlag(ElementKind.System)));
}

return filters.Count == 0 ? default :
kind.HasFlag(ElementKind.System) ?
Intersect(filters) :
Union(filters);
if (filters.Count == 0)
{
switch (elementType)
{
case null: return Universe;
case false: return new ElementIsElementTypeFilter(inverted: true);
case true: return new ElementIsElementTypeFilter(inverted: false);
}
}

return kind.HasFlag(ElementKind.System) ? Intersect(filters) : Union(filters);
}

public static ElementFilter ElementIsElementTypeFilter(bool inverted = false) => inverted ?
Expand Down
4 changes: 2 additions & 2 deletions src/RhinoInside.Revit.GH/Components/ElementType/QueryTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
{
var elementCollector = collector.WherePasses(ElementFilter);

if (kind is object && CompoundElementFilter.ElementKindFilter(kind.Value, elementType: true) is ARDB.ElementFilter kindFilter)
elementCollector = elementCollector.WherePasses(kindFilter);
if (kind is object)
elementCollector = elementCollector.WherePasses(CompoundElementFilter.ElementKindFilter(kind.Value, elementType: true));

if (category is object)
elementCollector.WhereCategoryIdEqualsTo(category.Id);
Expand Down
4 changes: 2 additions & 2 deletions src/RhinoInside.Revit.GH/Components/Family/QueryFamilies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ protected override void TrySolveInstance(IGH_DataAccess DA)
{
var elementCollector = collector.WherePasses(ElementFilter);

if (kind is object && CompoundElementFilter.ElementKindFilter(kind.Value, elementType: true) is ARDB.ElementFilter kindFilter)
elementCollector = elementCollector.WherePasses(kindFilter);
if (kind is object)
elementCollector = elementCollector.WherePasses(CompoundElementFilter.ElementKindFilter(kind.Value, elementType: true));

if (category is object)
elementCollector = elementCollector.WhereCategoryIdEqualsTo(category.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ protected override void RegisterInputParams(GH_InputParamManager manager)
Name = "Kind", NickName = "K",
Description = "Kind to match",
Optional = true
}.
SetDefaultVale(ElementKind.System | ElementKind.Component)
}
);

manager[manager.AddTextParameter("Family Name", "FN", "Family Name to match", GH_ParamAccess.item)].Optional = true;
Expand All @@ -139,13 +138,9 @@ protected override void TrySolveInstance(IGH_DataAccess DA)

if (familyName is object)
filters.Add(CompoundElementFilter.ElementFamilyNameFilter(familyName, inverted.Value));
//else
// filters.Add(CompoundElementFilter.ElementFamilyNameFilter(string.Empty, inverted: true));

if (typeName is object)
filters.Add(CompoundElementFilter.ElementTypeNameFilter(typeName, inverted.Value));
else if (familyName is null)
filters.Add(CompoundElementFilter.ElementTypeNameFilter(string.Empty, inverted: true));

var filter = inverted.Value ? CompoundElementFilter.Union(filters) : CompoundElementFilter.Intersect(filters);
DA.SetData("Filter", filter);
Expand Down
Loading