GPencil: GPencilStrokePoints.weight_get throws an "index out of range" error for Vertex groups IDs with no points assigned #87790
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#87790
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.71
Blender Version
Broken: version: 2.93.0 Beta, branch: master, commit date: 2021-04-21 20:15, hash:
0f66dbea90
Worked: (newest version of Blender that worked as expected)
Short description of error
GPencilStrokePoints.weight_get throws an "index out of range" error for Vertex groups IDs with no points assigned
Exact steps for others to reproduce the error
Create a Grease pencil stroke.
Create a vertex group
In a text window create a new file and run the following script
Added subscriber: @maumemoli
Added subscriber: @antoniov
The python api is not designed to check if the data is valid or not, just try to get the data.
I have checked and the first message is: "Groups: No groups for this stroke" The reason is the stroke hasn't any group, only the object.
If you assign a weight to the stroke, then you need pass the correct index. If the index is incorrect, you get the mensaje: "GPencilStrokePoints: index out of range"
This is the underlying C code:
BKE_report(reports, RPT_ERROR, "GPencilStrokePoints: index out of range");
return -1.0f;
}```
weight = gps.points.weight_get(vertex_group_index=0, point_index=i)
print(i, weight)
i += 1```
Changed status from 'Needs Triage' to: 'Needs User Info'
GPencilStrokePoints.weight_get throws an "index out of range" error for Vertex groups IDs with no points assignedto GPencil: GPencilStrokePoints.weight_get throws an "index out of range" error for Vertex groups IDs with no points assignedI understand what you mean and I think it should work that way
Now my question is on how I can check if the strokePoints I am iterating are assigned to a vertex group without getting any error.
I guess it is complicated to have the vertex groups values available in the strokePoints as it is for vertices.
Shall I just use a "try" and let it continue if there is a exception?
Any help is really appreciated.
Added subscriber: @lichtwerk
Changed status from 'Needs User Info' to: 'Archived'
As soon as any point has a weight assigned, the unassigned will return a value of -1.0.
Only if none is assigned at all, you'll get the
Error: Groups: index out of range
.So you are probably best of doing a check prior to the loop if any points are in the group [try/except is not nice, but possibly your best friend here].
Then if that check succeeds, you should be able to loop over all points (and the ones returning -1.0 weight are not assigned).
Mesh vertices have the
groups
property (https://docs.blender.org/api/master/bpy.types.MeshVertex.html#bpy.types.MeshVertex.groups) which can be utalized in similar mesh cases, maybe that should be implemented for stroke points at some point, I would not consider the current behavior a bug though, will archive for now (of course feel free to comment again if issues persist).I agree with you Philippe,
this is more of a feature request. I guess I will go with the try, except solution.
Thank you for the help.