M
by Max on 8 Aug 2022, edited 10 Aug 2022
#
I am reading overallheight from an IFC in Blenderbim but realized that the value varies with the units of the IFC-file. I have seen meters and millimeters but I guess the could be imperial as well. Does somebody know how I can get the units of the IFC-file with python in BlenderBIM?
T
by theoryshaw on 9 Aug 2022
#
How about this?...
import bpy
import ifcopenshell
import blenderbim.bim.import_ifc
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
Ifc = ifcopenshell.open('D:/Dropbox/GitLab/FreeMVD_WorkFlow/Random_Tests/Wall_Types/IFC4/from_BlenderBIM/Wall_Types_2.ifc')
'''
# If you already have the IFC imported into BB
#Ifc = ifcopenshell.open(IfcStore.path)
'''
# The first way through ifcopenshell-python api
assigned_units = Ifc.by_type("IfcUnitAssignment")
for IfcUnitAssignment in assigned_units:
#print(IfcUnitAssignment)
for IfcConversionBasedUnit in IfcUnitAssignment:
#print(IfcConversionBasedUnit)
for Unit in IfcConversionBasedUnit:
print(Unit)
'''
#The second way through BB api
assigned_units = tool.Ifc.get().by_type("IfcUnitAssignment")
for IfcUnitAssignment in assigned_units:
#print(IfcUnitAssignment)
for IfcConversionBasedUnit in IfcUnitAssignment:
#print(IfcConversionBasedUnit)
for Unit in IfcConversionBasedUnit:
print(Unit)
'''
M
by Max on 10 Aug 2022
#
Thanks a lot. I tried the fuction and among other things got LENGTHUNIT that I guess what I am looking for. The format was #21=IfcSIUnit(*,.LENGTHUNIT.,$,.METRE.)
#22=IfcSIUnit(*,.AREAUNIT.,$,.SQUARE_METRE.)
#23=IfcSIUnit(*,.VOLUMEUNIT.,$,.CUBIC_METRE.)
#27=IfcConversionBasedUnit(#25,.PLANEANGLEUNIT.,'DEGREE',#26)
...
and I wonder if you know how to call it to get "METRE". Also I wonder what units to expect? Is it MILLI, MILLI METRE or MILLI.METRE and how about imperial units like length of a dead kings foot or wingspan of a bald eagle?
T
by theoryshaw on 10 Aug 2022
#
Here's a more refined script that can tell if there's conversion based units, like imperial units, in the file...
Basically just prints out the unit of length.
Also, here's some standard designations for IfcConversionBasedUnit
and here's a list of designations for IfcSIUnitName
import bpy
import ifcopenshell
import blenderbim.bim.import_ifc
import blenderbim.tool as tool
from blenderbim.bim.ifc import IfcStore
Ifc = ifcopenshell.open('D:/Dropbox/GitLab/FreeMVD_WorkFlow/Random_Tests/Units/from_BlenderBIM/Metric.ifc')
'''
# If you already have the IFC imported into BB
#Ifc = ifcopenshell.open(IfcStore.path)
'''
ConversionBasedUnits = Ifc.by_type("IfcConversionBasedUnit")
IfcSIUnits = Ifc.by_type("IfcSIUnit")
if ConversionBasedUnits:
#print(ConversionBasedUnits)
for Unit in ConversionBasedUnits:
if Unit[1]== 'LENGTHUNIT':
print(Unit[2])
else:
#print(IfcSIUnits)
for Unit in IfcSIUnits:
if Unit[1]== 'LENGTHUNIT':
print(Unit[3])