GPv3: Python API for frame, drawing and drawing attributes #124787
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#124787
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "filedescriptor/blender:gpv3-drawing-python-api"
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?
This is a PR that is built on top of #122094 (thanks to @SietseB for the initial work).
Adds the following properties and functions:
layer.frames
,layer.frames.new(frame_number)
layer.frames.remove(frame_number)
layer.frames.copy(from, to)
frame = layer.get_frame_at(frame_number)
frame.drawing
frame.frame_number
frame.select
: the selection state of the keyframe in the dope sheetframe.keyframe_type
drawing = frame.drawing
drawing.type
(DRAWING
/REFERENCE
)drawing.user_count
: The number of keyframes that use this drawingdrawing.attributes
: attribute read/write access to the drawing dataTo be able to access attributes on drawings, a new
AttributeOwnerType::GreasePencilDrawing
is added.The API in
BKE_attributes.h
is updated to handle this type.In
rna_attributes.cc
, there is a newrna_def_attribute_group_grease_pencil_drawing
that defines the attribute group. For this to work, it also defines its own rna callback functions.@blender-bot build
Just some cleanup comments.
@ -1018,6 +1018,9 @@ inline bool GreasePencil::has_active_group() const
return (this->active_node != nullptr) && (this->active_node->wrap().is_group());
}
bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing * /*drawing*/,
remove comment
@ -712,3 +744,1 @@
static void rna_AttributeGroup_update_active_color(Main * /*bmain*/,
Scene * /*scene*/,
PointerRNA *ptr)
static void rna_AttributeGroupID_update_active_color(Main * /*bmain*/,
Should probably be moved in the
ID
section above@ -1465,0 +1624,4 @@
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Attribute");
RNA_def_property_ui_text(prop, "Active Attribute", "Active attribute");
RNA_def_property_pointer_funcs(prop,
Does this need a poll function? I think right now you could call this with an arbitrary drawing from different geometry and it would still try to set the active layer by name. Not a huge issue i guess, but maybe should be handled.
Hm not sure I follow. What would the poll function do?
It would check if the attribute layer given as a parameter is actually owned by the drawing, and cancel if not (rather than try and find a layer with the same name).
rna_AttributeGroupID_update_active_color
up 96050f6218frame.keyframe_type
01a3a19bdeactive
drawing attribute setter 92225140f5Didn't finish the review yet, will have a closer look soon!
@ -819,0 +907,4 @@
static bool rna_AttributeGroupGreasePencilDrawing_active_poll(PointerRNA *ptr,
const PointerRNA value)
{
AttributeOwner owner = owner_from_attribute_pointer_rna(&value);
Sorry about that, fixed now.
const_cast
35c9c6678dLGTM and also works in my basic tests.
The main thing that confused me at first was that
instance_drawing
didn't lead to a drawing of typeREFERENCE
, but that then made sense given the data model. I don't really have any specific recommendation that could avoid this initial confusion unfortunately.@blender-bot build
@blender-bot build
rna_enum_keyframe_type_items
cb8af525554c03e2b718
tocb8af52555
From code side of thing it looks essentially good to me, besides a few comments below.
Would be good to have some python-based tests of this API as part of the PR though?
@ -1465,0 +1638,4 @@
nullptr,
"rna_AttributeGroupGreasePencilDrawing_active_poll");
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
RNA_def_property_update(prop, 0, "rna_AttributeGroupID_update_active");
I find it weird to use a function named
rna_AttributeGroupID_update_active
for non-ID-owned attribute data?Would suggest to either rename that one to a generic
rna_AttributeGroup_update_active
name, or to add arna_AttributeGroupGreasePencilDrawing_update_active
one (which could then callrna_AttributeGroupID_update_active
if it's fine to do so)?@ -77,0 +243,4 @@
return frame_number;
}
static void rna_Frame_frame_number_index_range(
Not sure I understand why you need to define and use this callback?
@ -545,0 +833,4 @@
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update");
}
static void rna_def_grease_pencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
Usually API definition should go into its own RNA file (
rna_grease_pencil_api.cc
)?Does this mean I should add a file+function for
frames
,layer
,layers
,layer_mask
,layer_group
?yes, one new file, and then move all the
rna_def_xxx_api()
functions there (they are also usually nameRNA_api_xxx
, see e.g.rna_mesh_api.cc
and itsRNA_api_mesh()
definition function.These API definition functions are also declared in the
rna_internal.hh
file.rna_AttributeGroupID_update_active
torna_AttributeGroup_update_active
721509d8bfrna_Frame_frame_number_index_range
3acb6e4129...
LGTM
@blender-bot build