M
by Max on 28 Jun 2022, edited 11 Jul 2022
#
I wonder if somebody knows how to get OverallHeight and Width from a selected IFCWindow? I guess you first need to determine if they have these attributes. I just tried
from bpy import context as C
for ob in C.selected_objects:
print (ob.OverallHeight)
but of cource it was not that simple
M
by Max on 30 Jun 2022
#
I thought the name might be a custom property and used bpy.data.objects[str(obj.name)]['name']) but no luck.
M
by Max on 11 Jul 2022
#
Ok, I solved it kind of
from blenderbim.bim.ifc import IfcStore
ifc_data = IfcStore.get_file()
windows = ifc_data.by_type('IfcWindow')
for window in windows:
print(window.OverallHeight)
print(window.OverallWidth)
gives me the height and width of all windows but the problem is that I want the user to select the windows like
import bpy
selection = bpy.context.selected_objects
for obj in selection:
if obj.name.startswith("IfcWindow"):
print (obj.OverallHeight)
but then I get AttributeError: 'Object' object has no attribute 'OverallHeight'
B
by bruno_perdigao on 11 Jul 2022
#
Hi @Max, I think the problem is that you are trying to access the IFC property through the Blender Object. You have to get the IFC entity from the Blender object first. I haven't fully tested it, but maybe this will work:
import bpy
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
ifc_data = IfcStore.get_file()
selection = bpy.context.selected_objects
for obj in selection:
if obj.name.startswith("IfcWindow"):
ifc_entity = tool.Ifc.get_entity(obj) #gets the Ifc Entity from the Blender object
print (ifc_entity.OverallHeight)
M
by Max on 11 Jul 2022
#
Thanks a lot, I suspected something like this. For some reason tool.Ifc.get_entity(obj) gets "None" and then AttributeError: 'NoneType' object has no attribute 'OverallHeight'
B
by bruno_perdigao on 11 Jul 2022
#
I tested with two different files, and it worked for me. Maybe it's something with the file?
M
by Max on 11 Jul 2022
#
+1 votes
I feel like a complete idiot. I downloaded the IFC from this forum but I guess it was too experimental. With a typical Revit file it worked fine. Thanks for all your help.