GreasePencilFrames.new produces GreasePencilFrame copy #127480

Closed
opened 2024-09-12 06:00:14 +02:00 by Kevin C. Burke · 5 comments
Contributor

Page Information
File: bpy.types.GreasePencilFrames.rst
Blender Version: 4.3
GreasePencilFrames Python API

Short description of error
bpy.types.GreasePencilFrames.new and bpy.types.GreasePencilFrames.copy
seem to share the same behaviour.

In the GreasePencilFrame API are two methods with seemingly identical results: new and copy both produce a copy of the current Grease Pencil Frame.

Expected behavior would be that new would produce a Blank Grease Pencil frame. In the Blender Code is the command,
this->add_empty_drawings(1);...is this frame supposed to be blank?

This script demonstrates the current API (assumes active object is a Grease Pencil with a layer named "Lines"):

import bpy
obj = bpy.context.object
if obj.type == "GREASEPENCIL":
    obj.data.layers["Lines"].frames.new(5)
    obj.data.layers["Lines"].frames.copy(from_frame_number=5,to_frame_number=9)
**Page Information** File: `bpy.types.GreasePencilFrames.rst` Blender Version: `4.3` [GreasePencilFrames Python API](https://docs.blender.org/api/4.3/bpy.types.GreasePencilFrames.html) **Short description of error** [bpy.types.GreasePencilFrames.new](https://docs.blender.org/api/4.3/bpy.types.GreasePencilFrames.html#bpy.types.GreasePencilFrames.new) and [bpy.types.GreasePencilFrames.copy](https://docs.blender.org/api/4.3/bpy.types.GreasePencilFrames.html#bpy.types.GreasePencilFrames.copy) seem to share the same behaviour. In the `GreasePencilFrame` API are two methods with seemingly identical results: `new` and `copy` both produce a copy of the current Grease Pencil Frame. Expected behavior would be that `new` would produce a Blank Grease Pencil frame. In the Blender Code is the command, [this->add_empty_drawings(1);](https://github.com/blender/blender/blob/c41bb20008747eccebca1113bb5967e4889e797c/source/blender/blenkernel/intern/grease_pencil.cc#L2329)...is this frame supposed to be blank? This script demonstrates the current API (assumes active object is a Grease Pencil with a layer named "Lines"): ``` import bpy obj = bpy.context.object if obj.type == "GREASEPENCIL": obj.data.layers["Lines"].frames.new(5) obj.data.layers["Lines"].frames.copy(from_frame_number=5,to_frame_number=9) ```
Kevin C. Burke added the
Status
Needs Triage
Type
Bug
labels 2024-09-12 06:00:15 +02:00
Member

Hi, thanks for the report. frames.new() still adds an empty keyframe/drawing. Just that viewport is not updated after command execution (missing depsgraph update). Will check

Hi, thanks for the report. `frames.new()` still adds an empty keyframe/drawing. Just that viewport is not updated after command execution (missing depsgraph update). Will check
Pratik Borhade added
Module
Grease Pencil
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-09-12 06:45:02 +02:00
Member

Looks like adding a recalc geometry in rna_Frames_frame_new would solve the issue, but I'm not sure if this is the correct way to go since I don't know if this recalculates all frames or just current frame. If it is just current frame then it's simple as this:

DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY);
Looks like adding a recalc geometry in `rna_Frames_frame_new` would solve the issue, but I'm not sure if this is the correct way to go since I don't know if this recalculates all frames or just current frame. If it is just current frame then it's simple as this: ``` DEG_id_tag_update(&grease_pencil.id, ID_RECALC_GEOMETRY); ```
Member

Haven't checked locally yet (was bisecting some bug).
Re. ID_RECALC_GEOMETRY, not sure either. But the flag is used more commonly so I guess it recalculates the current frame?
Feel free to make the PR.

Haven't checked locally yet (was bisecting some bug). Re. `ID_RECALC_GEOMETRY`, not sure either. But the flag is used more commonly so I guess it recalculates the current frame? Feel free to make the PR.
Author
Contributor

There is a bpy.ops.gpencil.recalc_geometry() operator for GreasePencil v2. It would be terrific to have for GPv3 as I'm having a lot of trouble seeing my Grease Pencil updates after changing the data through the API.

There is a `bpy.ops.gpencil.recalc_geometry()` operator for GreasePencil v2. It would be terrific to have for GPv3 as I'm having a lot of trouble seeing my Grease Pencil updates after changing the data through the API.
Member

There is a bpy.ops.gpencil.recalc_geometry() operator for GreasePencil v2. It would be terrific to have for GPv3

I think I can do it together in 1 PR.

Well I guess it's more appropriate to separate the operator to a new PR. I'll just commit this recalc geometry fix in main and make that one.

> There is a bpy.ops.gpencil.recalc_geometry() operator for GreasePencil v2. It would be terrific to have for GPv3 ~~I think I can do it together in 1 PR.~~ Well I guess it's more appropriate to separate the operator to a new PR. I'll just commit this recalc geometry fix in main and make that one.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-09-12 11:13:21 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#127480
No description provided.