-
Notifications
You must be signed in to change notification settings - Fork 113
Closed
Labels
Description
Describe the bug
Coordinates are not set automatically.
When using mesh.add_vertex(x=0, y=0, z=0) we have to add all coordinates manually. If I pass in mesh.add_vertex(x=1), y and z coordinates will not be created automatically as the mesh tutorial suggests and geometry methods will fail.
To Reproduce
Steps to reproduce the behavior:
- Context: file
mesh_example.py - Sample script
from compas.datastructures import Mesh
mesh = Mesh()
a = mesh.add_vertex() # x,y,z coordinates are optional and default to 0,0,0
b = mesh.add_vertex(x=1)
c = mesh.add_vertex(x=1, y=1)
d = mesh.add_vertex(y=1)
mesh.add_face([a, b, c, d])
print("mesh face: ", mesh.face)
print("topology method: ", mesh.vertex_neighbors(a, ordered=False))
print("geometry method: ", mesh.vertex_coordinates(a))
- Output of
$ python mesh_example.py:
mesh face: {0: [0, 1, 2, 3]}
topology method: [1, 3]
Traceback (most recent call last):
File "mesh_example.py", line 14, in <module>
print("geometry method: ", mesh.vertex_coordinates(a))
File "C:\Users\(...)\mesh_example.py", line 814, in vertex_coordinates
return [self.vertex[key][axis] for axis in axes]
File "C:\Users\(...)\mesh_example.py", line 814, in <listcomp>
return [self.vertex[key][axis] for axis in axes]
KeyError: 'x'
Expected behavior
Expected output to generate coordinates automatically.
Screenshots
Here is a screenshot of the mesh tutorial example:

Desktop (please complete the following information):
- OS: Windows 10
- Python version: 3.8.6
- Python package manager: conda
Additional context
If this is the code snippet, then it works.
from compas.datastructures import Mesh
mesh = Mesh()
a = mesh.add_vertex(x=0, y=0, z=0)
b = mesh.add_vertex(x=1, y=0, z=0)
c = mesh.add_vertex(x=1, y=1, z=0)
d = mesh.add_vertex(x=0, y=1, z=0)
mesh.add_face([a, b, c, d])
print("mesh face: ", mesh.face)
print("topology method: ", mesh.vertex_neighbors(a, ordered=False))
print("geometry method: ", mesh.vertex_coordinates(a))
Output:
mesh face: {0: [0, 1, 2, 3]}
topology method: [1, 3]
geometry method: [0, 0, 0]