GPv3: Python API additions to layer, layers, layer_groups #121797

Merged
Falk David merged 5 commits from SietseB/blender:gpv3-python-api-layer-layers into main 2024-05-23 13:51:26 +02:00
Member

This PR contains several additions to the GPv3 Python API for
layer_groups, layers and layer[key].

Layer groups
grease_pencil.layer_groups

  • .new(name, parent_group=None)
  • .remove(layer_group, keep_children=False)
  • .move(layer_group, 'UP'/'DOWN')
  • .move_top(layer_group)
  • .move_bottom(layer_group)
  • .move_to_layer_group(layer_group, parent_group)

Layers
grease_pencil.layers

  • .new(name, set_active=True, layer_group=None)
  • .remove(layer)
  • .move(layer, 'UP'/'DOWN')
  • .move_top(layer)
  • .move_bottom(layer)
  • .move_to_layer_group(layer, layer_group)

Layer
grease_pencil.layer[key]

  • .select
  • .lock
  • .matrix_local
  • .matrix_parent_inverse
  • .parent_group
This PR contains several additions to the GPv3 Python API for `layer_groups`, `layers` and `layer[key]`. **Layer groups** `grease_pencil.layer_groups` - `.new(name, parent_group=None)` - `.remove(layer_group, keep_children=False)` - `.move(layer_group, 'UP'/'DOWN')` - `.move_top(layer_group)` - `.move_bottom(layer_group)` - `.move_to_layer_group(layer_group, parent_group)` **Layers** `grease_pencil.layers` - `.new(name, set_active=True, layer_group=None)` - `.remove(layer)` - `.move(layer, 'UP'/'DOWN')` - `.move_top(layer)` - `.move_bottom(layer)` - `.move_to_layer_group(layer, layer_group)` **Layer** `grease_pencil.layer[key]` - `.select` - `.lock` - `.matrix_local` - `.matrix_parent_inverse` - `.parent_group`
Sietse Brouwer added 1 commit 2024-05-14 19:59:13 +02:00
Sietse Brouwer added this to the Grease Pencil project 2024-05-14 19:59:25 +02:00
Sietse Brouwer requested review from Falk David 2024-05-14 19:59:34 +02:00
Falk David requested changes 2024-05-15 16:57:15 +02:00
Falk David left a comment
Member

Thanks for working on this. Did a pass, added some comments.

Thanks for working on this. Did a pass, added some comments.
@ -513,0 +813,4 @@
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update");
/* Inverse local transform of layer. */
prop = RNA_def_property(srna, "matrix_local_inverse", PROP_FLOAT, PROP_MATRIX);
Member

I think it's easy enough to use matrix_local.inverted().

I think it's easy enough to use `matrix_local.inverted()`.
SietseB marked this conversation as resolved
@ -513,0 +831,4 @@
prop, "rna_GreasePencilLayer_matrix_parent_inverse_get", nullptr, nullptr);
/* Is parented. */
prop = RNA_def_property(srna, "is_parented", PROP_BOOLEAN, PROP_NONE);
Member

Since all layers are part of the root group, this is always true. I think this property is not needed.

Since all layers are part of the root group, this is always true. I think this property is not needed.
SietseB marked this conversation as resolved
@ -513,0 +837,4 @@
RNA_def_property_ui_text(prop, "Is Parented", "True when the layer parent object is set");
/* Layer group. */
prop = RNA_def_property(srna, "layer_group", PROP_POINTER, PROP_NONE);
Member

I think this should be "parent_group".

I think this should be `"parent_group"`.
SietseB marked this conversation as resolved
@ -533,2 +929,4 @@
RNA_def_property_ui_text(prop, "Active Layer", "Active Grease Pencil layer");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_SELECTED, nullptr);
prop = RNA_def_property(srna, "active_layer_index", PROP_INT, PROP_UNSIGNED);
Member

Is this necessary to expose? I don't see how this could be useful.

Is this necessary to expose? I don't see how this could be useful.
SietseB marked this conversation as resolved
Sietse Brouwer added 2 commits 2024-05-22 20:35:31 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
277b113c2c
Code review changes
Falk David approved these changes 2024-05-23 12:30:44 +02:00
Falk David left a comment
Member

Some minor comments, will accept.

Some minor comments, will accept.
@ -221,0 +351,4 @@
static GreasePencilLayer *rna_GreasePencil_layer_new(GreasePencil *grease_pencil,
const char *name,
bool set_active,
Member

Use const.

Use `const`.
SietseB marked this conversation as resolved
@ -221,0 +388,4 @@
static void rna_GreasePencil_layer_move(GreasePencil *grease_pencil,
PointerRNA *layer_ptr,
int direction)
Member

Use const.

Use `const`.
SietseB marked this conversation as resolved
@ -221,0 +442,4 @@
else {
layer_group = &grease_pencil->root_group();
}
grease_pencil->move_node_into(layer_node, *layer_group);
Member

I think layer_group_ptr->data could have been invalidated, so I'd put a

if (layer_group == nullptr) {
   return;
}

here.

I think `layer_group_ptr->data` could have been invalidated, so I'd put a ``` if (layer_group == nullptr) { return; } ``` here.
SietseB marked this conversation as resolved
Member

@blender-bot build

@blender-bot build
Sietse Brouwer added 2 commits 2024-05-23 13:38:44 +02:00
Falk David merged commit 180474aaee into main 2024-05-23 13:51:26 +02:00
Sietse Brouwer deleted branch gpv3-python-api-layer-layers 2024-05-23 16:39:20 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
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
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
2 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#121797
No description provided.