Skip to content

Commit

Permalink
fix import custom point attributes, fix #335
Browse files Browse the repository at this point in the history
  • Loading branch information
alemuntoni committed Nov 16, 2023
1 parent 3d7f77a commit add21dd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions pymeshlab/tests/example_custom_mesh_attributes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pymeshlab
import numpy


def example_custom_mesh_attributes():
Expand Down Expand Up @@ -51,3 +52,24 @@ def example_custom_mesh_attributes():
# - __ca_fs__: Custom Attribute Face Scalar;
# - __ca_fp__: Custom Attribute Face Point;
ms.save_current_mesh(output_path + 'cube_custom_attr.ply', binary=False, __ca_vs__v_attr=True)

# add a point attribute manually using numpy array

# generate numpy array
attrs = numpy.array([
[-0.5, -0.5, -0.5],
[0.5, -0.5, -0.5],
[-0.5, 0.5, -0.5],
[0.5, 0.5, -0.5],
[-0.5, -0.5, 0.5],
[0.5, -0.5, 0.5],
[-0.5, 0.5, 0.5],
[0.5, 0.5, 0.5]])

# add a new custom point attribute
m.add_vertex_custom_point_attribute(attrs, 'numpy_attr')

# get the attribute and print it
ret_attr = m.vertex_custom_point_attribute_matrix('numpy_attr')

print(ret_attr)
2 changes: 1 addition & 1 deletion src/meshlab

0 comments on commit add21dd

Please sign in to comment.