diff --git a/docs/static/images/guides/revit-walls-profile.png b/docs/static/images/guides/revit-walls-profile.png index aca8c6ada..159728d09 100644 Binary files a/docs/static/images/guides/revit-walls-profile.png and b/docs/static/images/guides/revit-walls-profile.png differ diff --git a/docs/static/images/guides/revit-walls-profilelines.png b/docs/static/images/guides/revit-walls-profilelines.png index d173f146a..9437040e4 100644 Binary files a/docs/static/images/guides/revit-walls-profilelines.png and b/docs/static/images/guides/revit-walls-profilelines.png differ diff --git a/src/RhinoInside.Revit.External/DB/CompoundElementFilter.cs b/src/RhinoInside.Revit.External/DB/CompoundElementFilter.cs index e78846110..c9ca97ba6 100644 --- a/src/RhinoInside.Revit.External/DB/CompoundElementFilter.cs +++ b/src/RhinoInside.Revit.External/DB/CompoundElementFilter.cs @@ -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) @@ -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 ? diff --git a/src/RhinoInside.Revit.GH/Components/ElementType/QueryTypes.cs b/src/RhinoInside.Revit.GH/Components/ElementType/QueryTypes.cs index 995e3553a..266ff8d33 100644 --- a/src/RhinoInside.Revit.GH/Components/ElementType/QueryTypes.cs +++ b/src/RhinoInside.Revit.GH/Components/ElementType/QueryTypes.cs @@ -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); diff --git a/src/RhinoInside.Revit.GH/Components/Family/QueryFamilies.cs b/src/RhinoInside.Revit.GH/Components/Family/QueryFamilies.cs index e2cd5042e..3a1f5cb36 100644 --- a/src/RhinoInside.Revit.GH/Components/Family/QueryFamilies.cs +++ b/src/RhinoInside.Revit.GH/Components/Family/QueryFamilies.cs @@ -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); diff --git a/src/RhinoInside.Revit.GH/Components/Filters/ElementGenericFilter.cs b/src/RhinoInside.Revit.GH/Components/Filters/ElementGenericFilter.cs index f56ac55c7..485e6339b 100755 --- a/src/RhinoInside.Revit.GH/Components/Filters/ElementGenericFilter.cs +++ b/src/RhinoInside.Revit.GH/Components/Filters/ElementGenericFilter.cs @@ -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; @@ -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);