mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
small fixes after d209cc9ff, added a test
This commit is contained in:
@@ -566,8 +566,8 @@ def convert(value, from_prefix, from_unit, to_prefix, to_unit):
|
||||
return value
|
||||
|
||||
|
||||
def calculate_unit_scale(ifc_file, unit_type='LENGTHUNIT'):
|
||||
"""Returns a unit scale factor to convert to and from IFC project length units and SI meters
|
||||
def calculate_unit_scale(ifc_file, unit_type="LENGTHUNIT"):
|
||||
"""Returns a unit scale factor to convert to and from IFC project units and SI units.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import pytest
|
||||
import test.bootstrap
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.util.unit as subject
|
||||
from math import pi
|
||||
|
||||
|
||||
class TestCalculateUnitScale(test.bootstrap.IFC4):
|
||||
@@ -30,6 +31,11 @@ class TestCalculateUnitScale(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, units=[length])
|
||||
assert subject.calculate_unit_scale(self.file) == 0.3048 * 0.001
|
||||
|
||||
angle = ifcopenshell.api.run("unit.add_conversion_based_unit", self.file, name="degree")
|
||||
angle.ConversionFactor.UnitComponent.Prefix = "MILLI"
|
||||
ifcopenshell.api.run("unit.assign_unit", self.file, units=[angle])
|
||||
assert subject.calculate_unit_scale(self.file, "PLANEANGLEUNIT") == pi / 180 * 0.001
|
||||
|
||||
|
||||
class TestFormatLength(test.bootstrap.IFC4):
|
||||
def test_run(self):
|
||||
|
||||
Reference in New Issue
Block a user