Clearing grease pencil data/frame/layer using python does not clear viewport #104121
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#104121
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: Linux-5.4.0-137-generic-x86_64-with-glibc2.31 64 Bits
Graphics card: NVIDIA GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.47.03
Blender Version
Broken: version: 3.5.0 Alpha
Worked: never? (doesn't work until 2.83)
Short description of error
When clearing grease pencil data using python API, the strokes are not disappearing in the viewport.
They do disappear when update is sent to viewport (eg. change object mode, attempt to draw stroke, etc.)
The same problem appear when clearing a grease pencil frame or layer.
Exact steps for others to reproduce the error
Open the "New 2D animation" template file.
Draw a stroke.
Open a Python console.
Type
C.active_object.data.clear()
to clear out data from grease pencil object.The stroke is still visible in viewport while all data from the object has been removed.
clear_data_update.mp4
Added subscriber: @amelief
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @PratikPB2123
Added subscriber: @antoniov
I have no idea where the "clear" data API is defined, but for sure this problem is a missing notifier. I guess the solution is find where this
clear
is done and check if theID
type isID_GD
.So far, I found that the API function is defined in
rna_gpencil.c:2726
, and is linked to therna_GPencil_clear
C function that is defined inrna_gpencil.c:1118
.This function calls a notifier :
WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
which should in theory re-draw the grease pencil object in the viewport, right ?I am not sure where to check for the ID type though.
Try adding
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
afterBKE_gpencil_free_layers(&gpd->layers);
inrna_GPencil_clear
Yay it works !
Now we only need to make it work for frame/layer clear functions, because they have as only parameter
bGPDframe*
/bGPDlayer*
which don't have anid
field.. (rna_gpencil:1104-1111
)@amelief Look at
rna_GPencil_stroke_remove
You need set this:
Then in the called function, just add the ID as parameter.
static void rna_GPencil_frame_clear(ID *id, bGPDframe *frame)
This issue was referenced by
ef39d85d7c
Changed status from 'Confirmed' to: 'Resolved'