diff --git a/CHANGELOG.md b/CHANGELOG.md index 90aadc97f34..f324813acdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,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. * `compas_rhino.uninstall` will try to remove compas packages from all possible install locations. * Changed `angle_vectors_projected` to raise `ValueError` when an input vector is parallel to projection normal. * Changed `angle_vectors` to raise `ValueError` when one of the input vectors is a zero-length vector instead of returning 0. diff --git a/src/compas/geometry/polyhedron.py b/src/compas/geometry/polyhedron.py index 68720119daa..c0cecdafecf 100644 --- a/src/compas/geometry/polyhedron.py +++ b/src/compas/geometry/polyhedron.py @@ -284,7 +284,9 @@ def vertices(self): @vertices.setter def vertices(self, vertices): - self._vertices = vertices + self._vertices = [] + for vertex in vertices: + self._vertices.append([*vertex]) @property def faces(self): 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)