Hi,
I’m trying to get the space number of the element from their Room Calculation Point.
It seems I have to use this class SpatialElementCalculationLocation but I don’t know how to use it :
For the moment I can get the Space number:
for s in SP:
numero = s.get_Parameter(BuiltInParameter.ROOM_NUMBER)
print(numero.AsString())
print(s.Id.IntegerValue)
And the location of the element :
for ME in MEs:
loc = ME.Location.Point
print(loc.X, loc.Y, loc.Z)
But I don’t know how to link them. Is there an API native way to do this or I have to build a script with the volume of the spaces and the element locations ?
I just replace item.Room by item.Space for my need.
I’m sharing my code for those who can help :
phase = doc.Phases[1]
MEs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_MechanicalEquipment).WhereElementIsNotElementType().ToElements()
def element_room(item,phase):
return item.Space[phase]
elements_spaces = [element_room(x,phase) for x in MEs]
print(elements_spaces[0].Name)
Hi @Yoann.Obry and @Jean-Marc!
I develop a script for this topic but with a different approach. My goal was to get the room name and number for my MEP element without the need to create MEP space. Use spaces only to get the room information isn’t the best use for the spaces. So, I use 3 method in the script to obtain the better result.
BoundingBox
Centroïd
Instance Origin
Once the script get where is the MEP element are located, I get the room name and number and i copy this information to my shared parameter. Finally, I get the same information if I compare with the spaces method, but more flexibilities because the data are store in shared parameter.
with forms.WarningBar(title="Select Space:"):
Element_space = revit.pick_element()
if type(Element_space) != DirectShape:
forms.alert('Select only the Space', exitscript=True)
print(type(Element_space))
Element_space_bb = Element_space.get_BoundingBox(None)
print(Element_space_bb)
All_pipes_in_View = FilteredElementCollector(doc,active_view.Id).OfCategory(BuiltInCategory.OST_PipeCurves).WhereElementIsNotElementType().ToElements()
all_fittings_in_View = FilteredElementCollector(doc,active_view.Id).OfCategory(BuiltInCategory.OST_PipeFitting).WhereElementIsNotElementType().ToElements()
all_Acessories_in_View = FilteredElementCollector(doc,active_view.Id).OfCategory(BuiltInCategory.OST_PipeAccessory).WhereElementIsNotElementType().ToElements()
all_pipeflex_in_View = FilteredElementCollector(doc,active_view.Id).OfCategory(BuiltInCategory.OST_FlexPipeCurves).WhereElementIsNotElementType().ToElements()
All_piping_elements = list(All_pipes_in_View) + list(all_fittings_in_View) + list(all_Acessories_in_View) + list(all_pipeflex_in_View) #pegando as 4 categorias de piping
for element in All_piping_elements:
a=element.get_BoundingBox(None)
now i have the bounding box for the geometry who i am using for space and i have the bounding box for the piping elements. How can i get the intersect of them? with this information i know how write(set) the value of space in the correct piping elements.