From 89e3ab2a4533439cdec6f72374b2e6053e2803e2 Mon Sep 17 00:00:00 2001 From: Falk David Date: Mon, 14 Oct 2024 10:28:59 +0200 Subject: [PATCH] Fix: GPv3: Error when calling `add_points` or `remove_points` The `drawing.resize_curves` function had been renamed in 1899ea25d5b994ab3e653272dbcf9cec954acf62 but this wasn't updated in the strokes API. --- .../_bpy_internal/grease_pencil/stroke.py | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/scripts/modules/_bpy_internal/grease_pencil/stroke.py b/scripts/modules/_bpy_internal/grease_pencil/stroke.py index a0e4881d0fc..8c31894a951 100644 --- a/scripts/modules/_bpy_internal/grease_pencil/stroke.py +++ b/scripts/modules/_bpy_internal/grease_pencil/stroke.py @@ -35,7 +35,8 @@ class AttributeGetterSetter: else: raise Exception("Unknown type {!r}".format(type)) else: - raise Exception("Could not create attribute {:s} of type {!r}".format(name, type)) + raise Exception( + "Could not create attribute {:s} of type {!r}".format(name, type)) class SliceHelper: @@ -115,13 +116,16 @@ def DefAttributeGetterSetters(attributes_list): # Define the list of attributes that should be exposed as read/write properties on the class. @DefAttributeGetterSetters([ # Property Name, Attribute Name, Type, Default Value, Doc-string. - ("position", "position", 'FLOAT_VECTOR', (0.0, 0.0, 0.0), "The position of the point (in local space)."), + ("position", "position", 'FLOAT_VECTOR', (0.0, 0.0, 0.0), + "The position of the point (in local space)."), ("radius", "radius", 'FLOAT', 0.01, "The radius of the point."), ("opacity", "opacity", 'FLOAT', 0.0, "The opacity of the point."), ("vertex_color", "vertex_color", 'FLOAT_COLOR', (0.0, 0.0, 0.0, 0.0), "The color for this point. The alpha value is used as a mix factor with the base color of the stroke."), - ("rotation", "rotation", 'FLOAT', 0.0, "The rotation for this point. Used to rotate textures."), - ("delta_time", "delta_time", 'FLOAT', 0.0, "The time delta in seconds since the start of the stroke."), + ("rotation", "rotation", 'FLOAT', 0.0, + "The rotation for this point. Used to rotate textures."), + ("delta_time", "delta_time", 'FLOAT', 0.0, + "The time delta in seconds since the start of the stroke."), ]) class GreasePencilStrokePoint(AttributeGetterSetter): """ @@ -181,14 +185,19 @@ class GreasePencilStrokePointSlice(SliceHelper): @DefAttributeGetterSetters([ # Property Name, Attribute Name, Type, Default Value, Doc-string. ("cyclic", "cyclic", 'BOOLEAN', False, "The closed state for this stroke."), - ("material_index", "material_index", 'INT', 0, "The index of the material for this stroke."), - ("softness", "softness", 'FLOAT', 0.0, "Used by the renderer to generate a soft gradient from the stroke center line to the edges."), + ("material_index", "material_index", 'INT', 0, + "The index of the material for this stroke."), + ("softness", "softness", 'FLOAT', 0.0, + "Used by the renderer to generate a soft gradient from the stroke center line to the edges."), ("start_cap", "start_cap", 'INT8', 0, "The type of start cap of this stroke."), ("end_cap", "end_cap", 'INT8', 0, "The type of end cap of this stroke."), - ("aspect_ratio", "aspect_ratio", 'FLOAT', 1.0, "The aspect ratio (x/y) used for textures. "), + ("aspect_ratio", "aspect_ratio", 'FLOAT', 1.0, + "The aspect ratio (x/y) used for textures. "), ("fill_opacity", "fill_opacity", 'FLOAT', 0.0, "The opacity of the fill."), - ("fill_color", "fill_color", 'FLOAT_COLOR', (0.0, 0.0, 0.0, 0.0), "The color of the fill."), - ("time_start", "init_time", 'FLOAT', 0.0, "A time value for when the stroke was created."), + ("fill_color", "fill_color", 'FLOAT_COLOR', + (0.0, 0.0, 0.0, 0.0), "The color of the fill."), + ("time_start", "init_time", 'FLOAT', 0.0, + "A time value for when the stroke was created."), ]) class GreasePencilStroke(AttributeGetterSetter): """ @@ -219,7 +228,8 @@ class GreasePencilStroke(AttributeGetterSetter): """ previous_end = self._points_end_index new_size = self._points_end_index - self._points_start_index + count - self._drawing.resize_curves(sizes=[new_size], indices=[self._curve_index]) + self._drawing.resize_strokes( + sizes=[new_size], indices=[self._curve_index]) self._points_end_index = self._points_start_index + new_size return GreasePencilStrokePointSlice(self._drawing, previous_end, self._points_end_index) @@ -231,7 +241,8 @@ class GreasePencilStroke(AttributeGetterSetter): # A stroke need to have at least one point. if new_size < 1: new_size = 1 - self._drawing.resize_curves(sizes=[new_size], indices=[self._curve_index]) + self._drawing.resize_strokes( + sizes=[new_size], indices=[self._curve_index]) self._points_end_index = self._points_start_index + new_size @property