Do you want a Python
solution per se.
What you want can be done with just
nodes AFAIK.
Also post the Python
code
if you need help with that.
Canât tell what the problem is by
just that image.
I using this script.
#Alban de Chasteigner 2019.txt (5.1 KB)
#Alban de Chasteigner 2019
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com
#GitHub - albandechasteigner/GeniusLociForDynamo: Genius Loci is a package of 350+ custom nodes for Dynamo in Revit.
import clr
clr.AddReference(âRevitNodesâ)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(âRevitAPIâ)
from Autodesk.Revit.DB import Category, FamilySymbol, FilteredElementCollector, Document, RevitLinkInstance, ElementParameterFilter, ElementMulticlassFilter, ElementMulticategoryFilter, FilterElementIdRule, ParameterValueProvider, FilterNumericEquals, ElementId, BuiltInCategory,BuiltInParameter, Level, HostObjAttributes
import System
from System.Collections.Generic import List
def tolist(obj1):
if hasattr(obj1,âiterâ): return obj1
else: return [obj1]
SelectedLevel = tolist(UnwrapElement(IN[0]))[0]
cats = tolist(UnwrapElement(IN[1]))
cats2 = tolist(UnwrapElement(IN[2]))
doc = SelectedLevel.Document
elem =
#ueWrapper by Dimitar Venkov
ueWrapper = None
wrappers = clr.GetClrType(Revit.Elements.ElementWrapper).GetMethods()
for w in wrappers:
if w.ToString().startswith(âRevit.Elements.UnknownElementâ):
ueWrapper = w
break
provider = ParameterValueProvider(ElementId(BuiltInParameter.ELEM_FAMILY_PARAM))
provider2 = ParameterValueProvider(ElementId(BuiltInParameter.ELEM_TYPE_PARAM))
evaluator = FilterNumericEquals()
for cat in cats:
if isinstance(cat, Category):
catId = List[ElementId](x.Id for x in cats)
filter = ElementMulticategoryFilter(catId)
fec = FilteredElementCollector(doc).WhereElementIsNotElementType()
elif isinstance(cat, System.Type):
catId = ListSystem.Type
filter = ElementMulticlassFilter(catId)
fec = FilteredElementCollector(doc)
elif isinstance(cat, FamilySymbol):
filter = ElementParameterFilter(FilterElementIdRule(provider, evaluator, cat.Id))
fec = FilteredElementCollector(doc).OfCategoryId(cat.Category.Id)
elif isinstance(cat, HostObjAttributes):
filter = ElementParameterFilter(FilterElementIdRule(provider2, evaluator, cat.Id))
fec = FilteredElementCollector(doc).OfCategoryId(cat.Category.Id)
for cat in cats:
if isinstance(cat, Category):
catId = List[ElementId](x.Id for x in cats)
filter = ElementMulticategoryFilter(catId)
fec = FilteredElementCollector(doc).WhereElementIsNotElementType()
elif isinstance(cat, System.Type):
catId = ListSystem.Type
filter = ElementMulticlassFilter(catId)
fec = FilteredElementCollector(doc)
elif isinstance(cat, FamilySymbol):
filter = ElementParameterFilter(FilterElementIdRule(provider, evaluator, cat.Id))
fec = FilteredElementCollector(doc).OfCategoryId(cat.Category.Id)
elif isinstance(cat, HostObjAttributes):
filter = ElementParameterFilter(FilterElementIdRule(provider2, evaluator, cat.Id))
fec = FilteredElementCollector(doc).OfCategoryId(cat.Category.Id)
collector = fec.WherePasses(filter)
#Inspired by Clockwork
def GetLevel(item):
val = None
if hasattr(item, âLevelIdâ):
val = item.Document.GetElement(item.LevelId)
if val: return val
if hasattr(item, âLevelâ):
val = item.Level
if val: return val
if hasattr(item, âGenLevelâ):
val = item.GenLevel
if val: return val
if (item.GetType().ToString() in (âAutodesk.Revit.DB.Architecture.StairsRunâ, âAutodesk.Revit.DB.Architecture.StairsLandingâ)):
item = item.GetStairs()
if (item.GetType().ToString() == âAutodesk.Revit.DB.Architecture.Stairsâ) or item.Category.Id == ElementId(BuiltInCategory.OST_Ramps):
try: return item.Document.GetElement(item.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM).AsElementId())
except: pass
if (item.GetType().ToString() == âAutodesk.Revit.DB.ExtrusionRoofâ):
try: return item.Document.GetElement(item.get_Parameter(BuiltInParameter.ROOF_CONSTRAINT_LEVEL_PARAM).AsElementId())
except: pass
if (item.GetType().ToString() == âAutodesk.Revit.DB.Mechanical.Ductâ or âAutodesk.Revit.DB.Electrical.Conduitâ):
try: return item.Document.GetElement(item.get_Parameter(BuiltInParameter.RBS_START_LEVEL_PARAM).AsElementId())
except: pass
if hasattr(item, âOwnerViewIdâ):
view = item.Document.GetElement(item.OwnerViewId)
if hasattr(view, âGenLevelâ):
val = view.GenLevel
if val: return val
if not val:
try: return item.Document.GetElement(item.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsElementId())
except:
try: return item.Document.GetElement(item.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId())
except:
try: return item.Document.GetElement(item.get_Parameter(BuiltInParameter.SCHEDULE_LEVEL_PARAM).AsElementId())
except:
#if item is work plane based
collector = FilteredElementCollector(item.Document).OfClass(Level).ToElements()
try: return [level for level in collector if item.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM).AsString().split(": ")[-1] == level.Name][0]
except: return None
for col in collector :
if GetLevel(col) and GetLevel(col).Id == SelectedLevel.Id:
try:
elem.append(col.ToDSType(True))
except:
if ueWrapper:
elem.append(ueWrapper.Invoke(None,(col, True)))
OUT = elem
collector.Dispose()
filter.Dispose()
Thanks for advice, i will try to my dynamo.
Sorry sir. Where can i find Rebars.Hostâs node?



