GPv3: Python API #116043
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116043
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?
The python API for grease pencil needs to be ported to the new data-structure.
We're expecting to break compatibility with the current API.
Instead of trying to replicate the old API exactly, we should focus on covering all the functionality. This means that some endpoints might change the way they are named, the way they are used, etc. but generally the same functionality should be archivable (with a bit of translation).
Changes to the data-structure
object.data.layers
can stay exactly the same. We define a collection that lists the layers from bottom-most to top-mostlayer.frames
can also stay the same, but...GreasePencilFrame
should have a propertydrawing
that points to theGreasePencilDrawing
. A frame no longer contains a list ofstrokes
.GreasePencilDrawing
has a type ('DRAWING'
or'REFERENCE'
?) . This is the struct that cointains the geometry.Iterating over the strokes should be replaced by aCurveSlice
iterator similar to what is done inrna_def_curves_curve
.We can do something similar forpoints
.strokes
of typeStroke
Stroke
property has twoint
properties:start
andend
. They are the offset indices into the data arrays.num_points
andnum_strokes
since callinglen(...)
is a bit expensive.strokes.new
currently creates one stroke at a time.Drawing
in rna functions:PointerRNA
only knows about thedata
it points to and theID
that thedata
is owned by. This means that in practice we have to do a search to find theparent
.Drawing
and some substructure inside it, this may look something like this:Tasks
Complete list of Grease Pencil Python API endpoints
Object data API:
after_color
prop
before_color
prop
clear
function
curve_edit_corner_angle
prop
curve_edit_threshold
prop
edit_curve_resolution
prop
edit_line_color
prop
ghost_after_range
prop
ghost_before_range
prop
grid
prop
is_annotation
prop
is_stroke_paint_mode
prop
is_stroke_sculpt_mode
prop
is_stroke_vertex_mode
prop
is_stroke_weight_mode
prop
layers
collection
materials
collection
onion_factor
prop
onion_keyframe_type
prop
onion_mode
prop
pixel_factor
prop
stroke_depth_order
prop
stroke_thickness_space
prop
use_adaptive_curve_resolution
prop
use_autolock_layers
prop
use_curve_edit
prop
use_ghost_custom_colors
prop
use_ghosts_always
prop
use_multiedit
prop
use_onion_fade
prop
use_onion_loop
prop
use_onion_skinning
prop
use_stroke_edit_mode
prop
zdepth_offset
prop
Grid API:
color
prop
Grid
API should be moved to the overlay settings.lines
prop
offset
prop
scale
prop
Layers (Collection) API:
active_index
prop
active_note
prop
active
prop
None
if there is no active layer.move
function
new
function
remove
function
Layer API:
active_frame
prop
annotation_hide
prop
annotation_onion_after_color
prop
annotation_onion_after_range
prop
annotation_onion_before_color
prop
annotation_onion_before_range
prop
annotation_opacity
prop
blend_mode
prop
channel_color
prop
clear
function
color
prop
frames
collection
hide
prop
info
prop
is_parented
prop
is_ruler
prop
line_change
prop
location
prop
lock
prop
lock_frame
prop
lock_material
prop
mask_layers
collection
matrix_inverse
prop
matrix_inverse_layer
prop
matrix_layer
prop
opacity
prop
parent
prop
parent_bone
prop
parent_type
prop
pass_index
prop
rna_type
prop
rotation
prop
scale
prop
select
prop
show_in_front
prop
show_points
prop
thickness
prop
tint_color
prop
tint_factor
prop
use_annotation_onion_skinning
prop
use_lights
prop
use_mask_layer
prop
use_onion_skinning
prop
use_solo_mode
prop
use_viewlayer_masks
prop
vertex_paint_opacity
prop
viewlayer_render
prop
Frames (Collection) API:
active
prop
copy
function
new
function
remove
function
Masks (Collection) API:
active_mask_index
prop
add
function
remove
function
Frame API:
clear
function
frame_number
prop
is_edited
prop
keyframe_type
prop
select
prop
strokes
collection
GreasePencilDrawing
Mask API:
hide
prop
invert
prop
name
prop
Strokes (Collection) API:
close
function
new
function
remove
function
Stroke API:
aspect
prop
bound_box_max
prop
bound_box_min
prop
display_mode
prop
edit_curve
prop
end_cap_mode
prop
hardness
prop
has_edit_curve
prop
is_nofill_stroke
prop
line_width
prop
material_index
prop
points
collection
select_index
prop
select
prop
start_cap_mode
prop
time_start
prop
triangles
collection
use_cyclic
prop
uv_rotation
prop
uv_scale
prop
uv_translation
prop
vertex_color_fill
prop
Points (Collection) API:
add
function
pop
function
update
function
weight_get
function
weight_set
function
Triangle API:
v1
prop
v2
prop
v3
prop
Point API:
co
prop
pressure
prop
select
prop
strength
prop
time
prop
uv_factor
prop
uv_fill
prop
uv_rotation
prop
vertex_color
prop
Edit Curve API:
curve_points
collection
select
prop
Edit Curve Point API:
co
prop
handle_left
prop
handle_right
prop
hide
prop
point_index
prop
pressure
prop
select_control_point
prop
select_left_handle
prop
select_right_handle
prop
strength
prop
uv_factor
prop
uv_rotation
prop
vertex_color
prop
I worked on a first draft for the Frame and Drawing API: #121407: WIP: GPv3: RNA for frame, drawing, stroke and point.
We have to decide how we expose the curves geometry data in the API. As I see it, there are two options.
Proposal: Keep close to GPv2, define
drawing.strokes
anddrawing.strokes[].points
Python object structure:
frame = layer.frames[index]
drawing = frame.drawing
stroke = drawing.strokes[index]
point = stroke.points[index]
Properties of
stroke
:index
,num_points
,use_cyclic
,select
,start_cap_mode
,end_cap_mode
,hardness
,aspect_ratio
,fill_color
,material_index
,init_time
Properties of
point
:position
,radius
,opacity
,vertex_color
,rotation
,select
,delta_time
Properties of stroke and point can be get/set in bulk: e.g.
drawing.strokes.foreach_get("material_index", array)
ordrawing.strokes[0].points.foreach_set("opacity", array)
.Pros:
stroke
is a stroke, not secretly an index, apoint.radius
is a float value, not an attribute object in aradii
collection.Cons:
Alternative: Define all attributes on
drawing
, use stroke and point indicesPython object structure:
frame = layer.frames[index]
drawing = frame.drawing
drawing.strokes[stroke_index]
ordrawing.stroke_points[stroke_index]
: gives thestart
andend
point index per strokedrawing.fill_colors[stroke_index]
for the fill color of strokesdrawing.vertex_colors[point_index]
for the vertex color of stroke pointsdrawing.radii[index]
drawing.positions[point_index].vector
for getting a point positiondrawing.radii[point_index].value
for getting a point radiusStroke and point attributes can be get/set in bulk: e.g.
drawing.positions.foreach_get("vector", array)
ordrawing.hardnesses.foreach_set("value", array)
.Pros:
Cons:
fill_colors
is in the curve domain,vertex_colors
is in the point domain. Or the domain can be part of the attribute name,stroke_fill_colors
, but that's pretty verbose.drawing.radii[]
, always return an object, not a straight value. So you have to writedrawing.radii[0].value = ...
instead ofdrawing.radii[0] = ...
. Which becomes annoying pretty quickly.I have my preference, but it is clearly something to discuss thoroughly at a meeting.