diff --git a/CHANGELOG.md b/CHANGELOG.md index 48f84651072..896a6c20816 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Renamed `Tolerance.units` to `Tolerance.unit` to better reflect the documented properties. Left `units` with deprecation warning. * Fixed `NotImplementedErorr` when calling `BrepLoop.vertices`. * Fixed `python -m compas` to detect extensions based on `importlib` rather than `pkg_resources`. +* Fixed `Polyhedron.vertices` setter to convert `Point` instances to `[x, y, z]` lists. ### Removed diff --git a/src/compas/geometry/polyhedron.py b/src/compas/geometry/polyhedron.py index 68720119daa..8169a3d81f9 100644 --- a/src/compas/geometry/polyhedron.py +++ b/src/compas/geometry/polyhedron.py @@ -284,6 +284,8 @@ def vertices(self): @vertices.setter def vertices(self, vertices): + if all(isinstance(vertex, Point) for vertex in vertices): + vertices = [[vertex.x, vertex.y, vertex.z] for vertex in vertices] self._vertices = vertices @property diff --git a/tests/compas/geometry/test_polyhedron.py b/tests/compas/geometry/test_polyhedron.py index 03763feeb61..87de040eb02 100644 --- a/tests/compas/geometry/test_polyhedron.py +++ b/tests/compas/geometry/test_polyhedron.py @@ -1,4 +1,5 @@ from compas.geometry import Polyhedron +from compas.geometry import Point from compas.itertools import pairwise @@ -17,3 +18,18 @@ def test_polyhedron(): assert polyhedron.lines == [(a, b) for a, b in pairwise(vertices[-1:] + vertices)] assert polyhedron.points[0] == vertices[0] assert polyhedron.points[-1] != polyhedron.points[0] + + +def test_polyhedron_vertices(): + vertices = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]] + faces = [[0, 1, 2, 3]] + name = "Test Polyhedron" + polyhedron = Polyhedron(vertices, faces, name) + + polyhedron_vertices = polyhedron.vertices + assert all(isinstance(vertex, list) and len(vertex) == 3 for vertex in polyhedron_vertices) + + vertices = [Point(0, 0, 0), Point(1, 0, 0), Point(1, 1, 0), Point(0, 1, 0)] + polyhedron = Polyhedron(vertices, faces, name) + polyhedron_vertices = polyhedron.vertices + assert all(isinstance(vertex, list) and len(vertex) == 3 for vertex in polyhedron_vertices)