From 5b007fd7bed926b3126cd144d1e7fca179b63db6 Mon Sep 17 00:00:00 2001 From: Anton Tetov Date: Wed, 7 Aug 2024 15:43:44 +0200 Subject: [PATCH] fix: SetColors expects an System.Array, loop instead --- CHANGELOG.md | 1 + src/compas_ghpython/drawing.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88a4ecdfeb29..8138c09e7515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Replaced use of `Rhino.Geometry.VertexColors.SetColors` with a for loop and `SetColor` in `compas_ghpyton` since the former requires a `System.Array`. * Changed the `__str__` of `compas.geometry.Frame`, `compas.geometry.Plane`, `compas.geometry.Polygon`, `compas.geometry.Polyhedron`, `compas.geometry.Quaternion` to use a limited number of decimals (determined by `Tolerance.PRECISION`). Note: `__repr__` will instead maintain full precision. * Changed the `__str__` of `compas.geometry.Pointcloud` to print total number of points instead of the long list of points. Note: `__repr__` will still print all the points with full precision. * Fixed bug in `Pointcloud.from_box()`. diff --git a/src/compas_ghpython/drawing.py b/src/compas_ghpython/drawing.py index 001fa4e3346e..5bf971a251f4 100644 --- a/src/compas_ghpython/drawing.py +++ b/src/compas_ghpython/drawing.py @@ -373,8 +373,10 @@ def draw_mesh(vertices, faces, color=None, vertex_normals=None, texture_coordina if color: count = len(mesh.Vertices) - colors = [rs.coercecolor(color) for i in range(count)] - mesh.VertexColors.SetColors(colors) + color = rs.CreateColor(color) + + for i in range(count): + mesh.VertexColors.SetColor(i, color.R, color.G, color.B) return mesh