Fix qto bug where cubic meter units are incorrectly converted.

This commit is contained in:
Dion Moult
2024-06-03 22:49:40 +10:00
parent 94c159ccd0
commit 2ea3fe4ab9
2 changed files with 11 additions and 2 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ class SI2ProjectUnitConverter:
"IfcLengthMeasure": "METRE",
"IfcMassMeasure": "GRAM",
"IfcTimeMeasure": "SECOND",
"IfcVolumeMeasure": "CUBIE_METRE",
"IfcVolumeMeasure": "CUBIC_METRE",
}
def convert(self, value, measure):
+10 -1
View File
@@ -16,13 +16,22 @@
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import pytest
import test.bootstrap
import ifcopenshell.api
import ifcopenshell.util.unit as subject
from math import pi
class TestConvert(test.bootstrap.IFC4):
def test_run(self):
assert subject.convert(1, None, "METRE", None, "METRE") == 1
assert subject.convert(1, None, "METRE", "MILLI", "METRE") == 1000
assert subject.convert(1000, "MILLI", "METRE", None, "METRE") == 1
assert subject.convert(1, None, "SQUARE_METRE", None, "SQUARE_METRE") == 1
assert subject.convert(1, None, "SQUARE_METRE", "MILLI", "SQUARE_METRE") == 1000000
assert subject.convert(1, None, "CUBIC_METRE", "MILLI", "CUBIC_METRE") == 1000000000
class TestCalculateUnitScale(test.bootstrap.IFC4):
def test_prefix_and_conversion_based_units_are_considered(self):
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")