migrate code to GPV3 (still problem with UV fill not set on point anymore)

This commit is contained in:
pullusb
2025-05-26 18:36:06 +02:00
parent 0bd062d212
commit 87c27c12d3
7 changed files with 50 additions and 36 deletions
+5 -5
View File
@@ -11,8 +11,8 @@ from .. constants import BGCOL, MODULE_DIR
## Plane conversion between multiple types: GP plane / image plane / empty references
def convert_background_image(ob, target = 'GPENCIL'):
'''Target in ['GPENCIL', 'EMPTY', 'MESH']'''
def convert_background_image(ob, target = 'GREASEPENCIL'):
'''Target in ['GREASEPENCIL', 'EMPTY', 'MESH']'''
if target == ob.type:
print('WARNING', f'{ob.name} Already of type {target}')
@@ -49,7 +49,7 @@ def convert_background_image(ob, target = 'GPENCIL'):
## TODO: ensure image filepath is ok ?
suffix = ''
if target == 'GPENCIL':
if target == 'GREASEPENCIL':
## Create GP plane from Texture source
new = core.import_image_as_gp_reference(
image_data,
@@ -122,9 +122,9 @@ class BPM_OT_convert_planes(Operator):
bl_options = {"REGISTER"} # , "UNDO"
target_type : bpy.props.EnumProperty(
name="Convert To", description="", default='GPENCIL', options={'ANIMATABLE'},
name="Convert To", description="", default='GREASEPENCIL', options={'ANIMATABLE'},
items=(
('GPENCIL', 'Gpencil Object', 'Convert bg planes to gpencil objects', 0),
('GREASEPENCIL', 'Gpencil Object', 'Convert bg planes to gpencil objects', 0),
('EMPTY', 'Empty Reference', 'Convert bg planes to empty objects', 1),
('MESH', 'Texture Plane', 'Convert bg planes to mesh objects', 2),
))
+3 -3
View File
@@ -240,9 +240,9 @@ class BPM_OT_align_to_plane(Operator):
for l in o.data.layers:
for f in l.frames:
for s in f.strokes:
for s in f.drawing.strokes:
for p in s.points:
p.co = matrot @ p.co
p.position = matrot @ p.position
return {"FINISHED"}
@@ -341,7 +341,7 @@ class BPM_OT_create_and_place_in_camera(Operator):
## Create Object
prefs = core.get_addon_prefs()
gp_data = bpy.data.grease_pencils.new(ob_name)
gp_data = bpy.data.grease_pencils_v3.new(ob_name)
ob = bpy.data.objects.new(ob_name, gp_data)
ob.use_grease_pencil_lights = prefs.use_light
gp_data.edit_line_color[3] = prefs.edit_line_opacity