Skip to content

Commit 81958ea

Browse files
committed
fix: exception when calling geometry of compas.datastructures.Part without features assigned
1 parent 531e3f6 commit 81958ea

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5353
* Fixed `compas_ghpython.artists.VolMeshArtist.draw` and `compas_ghpython.artists.VolMeshArtist.draw_cells`.
5454
* Fixed `compas_rhino.artists.VolMeshArtist.draw` and `compas_rhino.artists.VolMeshArtist.draw_cells`.
5555
* Improved error messages when artist instance cannot be created.
56+
* Fixed exception when calculating geometry of `compas.datastructures.Part` without features.
5657

5758
### Removed
5859

src/compas/datastructures/assembly/part.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,17 @@ def frame(self, frame):
144144
def geometry(self):
145145
# TODO: this is a temp solution
146146
# TODO: add memoization or some other kind of caching
147-
A = Mesh.from_shape(self.shape)
148-
for shape, operation in self.features:
149-
A.quads_to_triangles()
150-
B = Mesh.from_shape(shape)
151-
B.quads_to_triangles()
152-
A = Part.operations[operation](A.to_vertices_and_faces(), B.to_vertices_and_faces())
153-
geometry = Shape(*A)
147+
if self.features:
148+
A = Mesh.from_shape(self.shape)
149+
for shape, operation in self.features:
150+
A.quads_to_triangles()
151+
B = Mesh.from_shape(shape)
152+
B.quads_to_triangles()
153+
A = Part.operations[operation](A.to_vertices_and_faces(), B.to_vertices_and_faces())
154+
geometry = Shape(*A)
155+
else:
156+
geometry = Shape(*self.shape.to_vertices_and_faces())
157+
154158
T = Transformation.from_frame_to_frame(Frame.worldXY(), self.frame)
155159
geometry.transform(T)
156160
return geometry

0 commit comments

Comments
 (0)