mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +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=[
|
items=[
|
||||||
("KILOGRAM", "Kilogram", "Kilograms"),
|
("KILOGRAM", "Kilogram", "Kilograms"),
|
||||||
("GRAM", "Gram", "Grams"),
|
("GRAM", "Gram", "Grams"),
|
||||||
("POUND", "Pound (Mass)", "Pounds"),
|
("POUND", "Pound", "Pounds"),
|
||||||
("OUNCE", "Ounce", "Ounces"),
|
("OUNCE", "Ounce", "Ounces"),
|
||||||
("TON", "Ton", "Metric Tons"),
|
("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"))
|
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"))
|
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"))
|
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"))
|
massunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("MASSUNIT").lower())
|
||||||
timeunit = ifc.run("unit.add_conversion_based_unit", name=unit.get_scene_unit_name("TIMEUNIT"))
|
|
||||||
|
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")
|
planeangleunit = ifc.run("unit.add_conversion_based_unit", name="degree")
|
||||||
ifc.run("unit.assign_unit", units=[lengthunit, areaunit, volumeunit, planeangleunit, massunit, timeunit])
|
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
|
unit = bim_props.volume_unit
|
||||||
elif unit_type == "MASSUNIT":
|
elif unit_type == "MASSUNIT":
|
||||||
unit = bim_props.mass_unit
|
unit = bim_props.mass_unit
|
||||||
if unit == "KILOGRAM":
|
if unit == "GRAM":
|
||||||
return "KILO"
|
|
||||||
elif unit == "GRAM":
|
|
||||||
return None
|
return None
|
||||||
|
elif unit == "KILOGRAM":
|
||||||
|
return "KILO"
|
||||||
elif unit == "TON":
|
elif unit == "TON":
|
||||||
return "MEGA"
|
return "MEGA"
|
||||||
elif unit in ["POUND", "OUNCE"]:
|
elif unit in ["POUND", "OUNCE"]:
|
||||||
return "CONVERSION"
|
return "CONVERSION"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
elif unit_type == "TIMEUNIT":
|
elif unit_type == "TIMEUNIT":
|
||||||
unit = bim_props.time_unit
|
unit = bim_props.time_unit
|
||||||
if unit == "SECOND":
|
if unit == "SECOND":
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return "CONVERSION"
|
return "CONVERSION"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
assert_never(unit_type)
|
assert_never(unit_type)
|
||||||
if "/" in unit:
|
if "/" in unit:
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ def add_conversion_based_unit(
|
|||||||
dimensions = ifcopenshell.util.unit.named_dimensions[unit_type]
|
dimensions = ifcopenshell.util.unit.named_dimensions[unit_type]
|
||||||
exponents = file.createIfcDimensionalExponents(*dimensions)
|
exponents = file.createIfcDimensionalExponents(*dimensions)
|
||||||
si_name = ifcopenshell.util.unit.si_type_names[unit_type]
|
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)
|
conversion_real = ifcopenshell.util.unit.si_conversions.get(name, 1)
|
||||||
value_component = file.create_entity("IfcReal", **{"wrappedValue": conversion_real})
|
value_component = file.create_entity("IfcReal", **{"wrappedValue": conversion_real})
|
||||||
|
|||||||
Reference in New Issue
Block a user