mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
use kilogram as default for SI and Seconds for Imperial
This commit is contained in:
@@ -590,7 +590,7 @@ class BIMProperties(PropertyGroup):
|
||||
items=[
|
||||
("KILOGRAM", "Kilogram", "Kilograms"),
|
||||
("GRAM", "Gram", "Grams"),
|
||||
("POUND", "Pound (Mass)", "Pounds"),
|
||||
("POUND", "Pound", "Pounds"),
|
||||
("OUNCE", "Ounce", "Ounces"),
|
||||
("TON", "Ton", "Metric Tons"),
|
||||
],
|
||||
|
||||
@@ -52,8 +52,13 @@ def assign_scene_units(ifc: type[tool.Ifc], unit: type[tool.Unit]) -> None:
|
||||
lengthunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("LENGTHUNIT"))
|
||||
areaunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("AREAUNIT"))
|
||||
volumeunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("VOLUMEUNIT"))
|
||||
massunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("MASSUNIT"))
|
||||
timeunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("TIMEUNIT"))
|
||||
massunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("MASSUNIT").lower())
|
||||
|
||||
time_unit_name = unit.get_scene_unit_name("TIMEUNIT")
|
||||
if time_unit_name == "SECOND":
|
||||
timeunit = ifc.run("unit.add_si_unit", unit_type="TIMEUNIT", prefix=None)
|
||||
else:
|
||||
timeunit = ifc.run("unit.add_conversion_based_unit", name=time_unit_name.lower())
|
||||
|
||||
planeangleunit = ifc.run("unit.add_conversion_based_unit", name="degree")
|
||||
ifc.run("unit.assign_unit", units=[lengthunit, areaunit, volumeunit, planeangleunit, massunit, timeunit])
|
||||
|
||||
@@ -365,24 +365,22 @@ class Unit(bonsai.core.tool.Unit):
|
||||
unit = bim_props.volume_unit
|
||||
elif unit_type == "MASSUNIT":
|
||||
unit = bim_props.mass_unit
|
||||
if unit == "KILOGRAM":
|
||||
return "KILO"
|
||||
elif unit == "GRAM":
|
||||
if unit == "GRAM":
|
||||
return None
|
||||
elif unit == "KILOGRAM":
|
||||
return "KILO"
|
||||
elif unit == "TON":
|
||||
return "MEGA"
|
||||
elif unit in ["POUND", "OUNCE"]:
|
||||
return "CONVERSION"
|
||||
else:
|
||||
return None
|
||||
|
||||
elif unit_type == "TIMEUNIT":
|
||||
unit = bim_props.time_unit
|
||||
if unit == "SECOND":
|
||||
return None
|
||||
else:
|
||||
return "CONVERSION"
|
||||
|
||||
else:
|
||||
assert_never(unit_type)
|
||||
if "/" in unit:
|
||||
|
||||
@@ -61,7 +61,11 @@ def add_conversion_based_unit(
|
||||
dimensions = ifcopenshell.util.unit.named_dimensions[unit_type]
|
||||
exponents = file.createIfcDimensionalExponents(*dimensions)
|
||||
si_name = ifcopenshell.util.unit.si_type_names[unit_type]
|
||||
si_unit = file.createIfcSIUnit(UnitType=unit_type, Name=si_name)
|
||||
|
||||
if unit_type == "MASSUNIT":
|
||||
si_unit = file.createIfcSIUnit(UnitType=unit_type, Name=si_name, Prefix="KILO")
|
||||
else:
|
||||
si_unit = file.createIfcSIUnit(UnitType=unit_type, Name=si_name)
|
||||
|
||||
conversion_real = ifcopenshell.util.unit.si_conversions.get(name, 1)
|
||||
value_component = file.create_entity("IfcReal", **{"wrappedValue": conversion_real})
|
||||
|
||||
Reference in New Issue
Block a user