From c205edd67b7dd512b3f02ef6f770843bda115645 Mon Sep 17 00:00:00 2001 From: brgix Date: Tue, 3 Feb 2026 14:43:08 -0500 Subject: [PATCH] Fixes spaceWidth --- .github/workflows/pull_request.yml | 2 +- pyproject.toml | 2 +- src/osut/osut.py | 2 +- tests/test_osut.py | 27 +++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b132536..876373a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11"] steps: - name: Check out repository diff --git a/pyproject.toml b/pyproject.toml index 5655d90..7bf9dbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "osut" -version = "0.8.1" +version = "0.8.2" description = "OpenStudio SDK utilities for Python" readme = "README.md" requires-python = ">=3.2" diff --git a/src/osut/osut.py b/src/osut/osut.py index 8102d95..582df1e 100644 --- a/src/osut/osut.py +++ b/src/osut/osut.py @@ -5554,7 +5554,7 @@ def spaceWidth(space=None) -> float: polyg = list(polyg) polyg.reverse() - res = realignedFace(polyg) + res = realignedFace(polyg, True) if not res["box"]: return 0 # A bounded box's 'height', at its narrowest, is its 'width'. diff --git a/tests/test_osut.py b/tests/test_osut.py index 43cec53..1719699 100644 --- a/tests/test_osut.py +++ b/tests/test_osut.py @@ -5944,6 +5944,33 @@ def test38_space_height_width(self): self.assertEqual(o.level(), DBG) translator = openstudio.osversion.VersionTranslator() + # Basic test: 'deep' space (vs X-axis). + vtx = openstudio.Point3dVector() + vtx.append(openstudio.Point3d(2,9,1)) + vtx.append(openstudio.Point3d(2,1,1)) + vtx.append(openstudio.Point3d(1,1,1)) + vtx.append(openstudio.Point3d(1,9,1)) + + model = openstudio.model.Model() + space = openstudio.model.Space(model) + floor = openstudio.model.Surface(vtx, model) + floor.setSpace(space) + self.assertAlmostEqual(osut.spaceWidth(space),1,3) + + # Basic test: 'narrow' space (vs X-axis). + vtx = openstudio.Point3dVector() + vtx.append(openstudio.Point3d(9,2,1)) + vtx.append(openstudio.Point3d(9,1,1)) + vtx.append(openstudio.Point3d(1,1,1)) + vtx.append(openstudio.Point3d(1,2,1)) + + model = openstudio.model.Model() + space = openstudio.model.Space(model) + floor = openstudio.model.Surface(vtx, model) + floor.setSpace(space) + self.assertAlmostEqual(osut.spaceWidth(space),1,3) + + # --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # path = openstudio.path("./tests/files/osms/in/warehouse.osm") model = translator.loadModel(path) self.assertTrue(model)