Begin port to GPv3 - change GP type

master
pullusb 2024-11-11 15:35:39 +01:00
parent 98ed92afe2
commit f5a78601b6
22 changed files with 96 additions and 96 deletions

View File

@ -57,7 +57,7 @@ class GP_OT_create_empty_frames(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'GPENCIL' return context.active_object is not None and context.active_object.type == 'GREASEPENCIL'
def invoke(self, context, event): def invoke(self, context, event):
# Possible preset with shortcut # Possible preset with shortcut

View File

@ -111,7 +111,7 @@ def create_gap_stroke(f, ob, tol=10, mat_id=None):
def create_closing_line(tolerance=0.2): def create_closing_line(tolerance=0.2):
for ob in bpy.context.selected_objects: for ob in bpy.context.selected_objects:
if ob.type != 'GPENCIL': if ob.type != 'GREASEPENCIL':
continue continue
mat_id = get_closeline_mat(ob)# get a the closing material mat_id = get_closeline_mat(ob)# get a the closing material
@ -241,7 +241,7 @@ class GPSTK_OT_extend_lines(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'GPENCIL' return context.active_object is not None and context.active_object.type == 'GREASEPENCIL'
# mode : bpy.props.StringProperty( # mode : bpy.props.StringProperty(
# name="mode", description="Set mode for operator", default="render", maxlen=0, subtype='NONE', options={'ANIMATABLE'}) # name="mode", description="Set mode for operator", default="render", maxlen=0, subtype='NONE', options={'ANIMATABLE'})
@ -306,7 +306,7 @@ class GPSTK_OT_change_closeline_length(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'GPENCIL' return context.active_object is not None and context.active_object.type == 'GREASEPENCIL'
layer_tgt : bpy.props.EnumProperty( layer_tgt : bpy.props.EnumProperty(
name="Extend layers", description="Choose which layer to target", name="Extend layers", description="Choose which layer to target",
@ -367,7 +367,7 @@ class GPSTK_OT_comma_finder(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.active_object is not None and context.active_object.type == 'GPENCIL' return context.active_object is not None and context.active_object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
ct = 0 ct = 0
@ -397,7 +397,7 @@ class GPSTK_PT_line_closer_panel(bpy.types.Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return (context.object is not None)# and context.object.type == 'GPENCIL' return (context.object is not None)# and context.object.type == 'GREASEPENCIL'
## draw stuff inside the header (place before main label) ## draw stuff inside the header (place before main label)
# def draw_header(self, context): # def draw_header(self, context):
@ -414,7 +414,7 @@ class GPSTK_PT_line_closer_panel(bpy.types.Panel):
layout.operator("gp.extend_close_lines", icon = 'SNAP_MIDPOINT') layout.operator("gp.extend_close_lines", icon = 'SNAP_MIDPOINT')
#diplay closeline visibility #diplay closeline visibility
if context.object.type == 'GPENCIL' and context.object.data.materials.get('closeline'): if context.object.type == 'GREASEPENCIL' and context.object.data.materials.get('closeline'):
row=layout.row() row=layout.row()
row.prop(context.object.data.materials['closeline'].grease_pencil, 'hide', text='Stop lines') row.prop(context.object.data.materials['closeline'].grease_pencil, 'hide', text='Stop lines')
row.operator("gp.change_close_lines_extension", text='Length', icon = 'DRIVER_DISTANCE') row.operator("gp.change_close_lines_extension", text='Length', icon = 'DRIVER_DISTANCE')

View File

@ -27,7 +27,7 @@ class GPTB_OT_load_brushes(bpy.types.Operator, ImportHelper):
# @classmethod # @classmethod
# def poll(cls, context): # def poll(cls, context):
# return context.object and context.object.type == 'GPENCIL' # return context.object and context.object.type == 'GREASEPENCIL'
filename_ext = '.blend' filename_ext = '.blend'

View File

@ -423,10 +423,10 @@ class GPCLIP_OT_copy_strokes(bpy.types.Operator):
#copy = bpy.props.BoolProperty(default=True) #copy = bpy.props.BoolProperty(default=True)
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
# if not context.object or not context.object.type == 'GPENCIL': # if not context.object or not context.object.type == 'GREASEPENCIL':
# self.report({'ERROR'},'No GP object selected') # self.report({'ERROR'},'No GP object selected')
# return {"CANCELLED"} # return {"CANCELLED"}
@ -452,10 +452,10 @@ class GPCLIP_OT_cut_strokes(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
# if not context.object or not context.object.type == 'GPENCIL': # if not context.object or not context.object.type == 'GREASEPENCIL':
# self.report({'ERROR'},'No GP object selected') # self.report({'ERROR'},'No GP object selected')
# return {"CANCELLED"} # return {"CANCELLED"}
@ -477,10 +477,10 @@ class GPCLIP_OT_paste_strokes(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
# if not context.object or not context.object.type == 'GPENCIL': # if not context.object or not context.object.type == 'GREASEPENCIL':
# self.report({'ERROR'},'No GP object selected to paste on') # self.report({'ERROR'},'No GP object selected to paste on')
# return {"CANCELLED"} # return {"CANCELLED"}
@ -510,7 +510,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator):
#copy = bpy.props.BoolProperty(default=True) #copy = bpy.props.BoolProperty(default=True)
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
pressure : bpy.props.BoolProperty(name='pressure', default=True, pressure : bpy.props.BoolProperty(name='pressure', default=True,
description='Dump point pressure attribute (already skipped if at default value)') description='Dump point pressure attribute (already skipped if at default value)')
@ -633,7 +633,7 @@ class GPCLIP_OT_paste_multi_strokes(bpy.types.Operator):
#copy = bpy.props.BoolProperty(default=True) #copy = bpy.props.BoolProperty(default=True)
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
org_frame = context.scene.frame_current org_frame = context.scene.frame_current

View File

@ -13,7 +13,7 @@ class GPTB_OT_cusor_snap(bpy.types.Operator):
# @classmethod # @classmethod
# def poll(cls, context): # def poll(cls, context):
# return context.object and context.object.type == 'GPENCIL' # return context.object and context.object.type == 'GREASEPENCIL'
def invoke(self, context, event): def invoke(self, context, event):
#print('-!SNAP!-') #print('-!SNAP!-')
@ -23,7 +23,7 @@ class GPTB_OT_cusor_snap(bpy.types.Operator):
return {"FINISHED"} return {"FINISHED"}
def execute(self, context): def execute(self, context):
if not context.object or context.object.type != 'GPENCIL': if not context.object or context.object.type != 'GREASEPENCIL':
self.report({'INFO'}, 'Not GP, Cursor surface project') self.report({'INFO'}, 'Not GP, Cursor surface project')
bpy.ops.view3d.cursor3d('INVOKE_DEFAULT', use_depth=True, orientation='NONE')#'NONE', 'VIEW', 'XFORM', 'GEOM' bpy.ops.view3d.cursor3d('INVOKE_DEFAULT', use_depth=True, orientation='NONE')#'NONE', 'VIEW', 'XFORM', 'GEOM'
return {"FINISHED"} return {"FINISHED"}

View File

@ -145,7 +145,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
## GP Use light disable ## GP Use light disable
if fix.set_gp_use_lights_off: if fix.set_gp_use_lights_off:
gp_with_lights = [o for o in context.scene.objects if o.type == 'GPENCIL' and o.use_grease_pencil_lights] gp_with_lights = [o for o in context.scene.objects if o.type == 'GREASEPENCIL' and o.use_grease_pencil_lights]
if gp_with_lights: if gp_with_lights:
problems.append(f'Disable "Use Lights" on {len(gp_with_lights)} Gpencil objects') problems.append(f'Disable "Use Lights" on {len(gp_with_lights)} Gpencil objects')
if apply: if apply:
@ -181,7 +181,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
if fix.list_gp_mod_vis_conflict: if fix.list_gp_mod_vis_conflict:
mod_viz_ct = 0 mod_viz_ct = 0
for o in context.scene.objects: for o in context.scene.objects:
if o.type == 'GPENCIL': if o.type == 'GREASEPENCIL':
for m in o.grease_pencil_modifiers: for m in o.grease_pencil_modifiers:
if m.show_viewport != m.show_render: if m.show_viewport != m.show_render:
vp = 'Yes' if m.show_viewport else 'No' vp = 'Yes' if m.show_viewport else 'No'
@ -201,7 +201,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
## check if GP modifier have broken layer targets ## check if GP modifier have broken layer targets
if fix.list_broken_mod_targets: if fix.list_broken_mod_targets:
for o in [o for o in bpy.context.scene.objects if o.type == 'GPENCIL']: for o in [o for o in bpy.context.scene.objects if o.type == 'GREASEPENCIL']:
lay_name_list = [l.info for l in o.data.layers] lay_name_list = [l.info for l in o.data.layers]
for m in o.grease_pencil_modifiers: for m in o.grease_pencil_modifiers:
if not hasattr(m, 'layer'): if not hasattr(m, 'layer'):
@ -277,7 +277,7 @@ class GPTB_OT_file_checker(bpy.types.Operator):
# problems.append(f"{fix_kf_type} GP onion skin filter to 'All type'") # problems.append(f"{fix_kf_type} GP onion skin filter to 'All type'")
# for ob in context.scene.objects:#from object # for ob in context.scene.objects:#from object
# if ob.type == 'GPENCIL': # if ob.type == 'GREASEPENCIL':
# ob.data.onion_keyframe_type = 'ALL' # ob.data.onion_keyframe_type = 'ALL'
#### --- print fix/problems report #### --- print fix/problems report
@ -574,7 +574,7 @@ class GPTB_OT_list_modifier_visibility(bpy.types.Operator):
def invoke(self, context, event): def invoke(self, context, event):
self.ob_list = [] self.ob_list = []
for o in context.scene.objects: for o in context.scene.objects:
if o.type != 'GPENCIL': if o.type != 'GREASEPENCIL':
continue continue
if not len(o.grease_pencil_modifiers): if not len(o.grease_pencil_modifiers):
continue continue
@ -612,7 +612,7 @@ class GPTB_OT_list_modifier_visibility(bpy.types.Operator):
def invoke(self, context, event): def invoke(self, context, event):
self.ob_list = [] self.ob_list = []
for o in context.scene.objects: for o in context.scene.objects:
if o.type == 'GPENCIL': if o.type == 'GREASEPENCIL':
if not len(o.grease_pencil_modifiers): if not len(o.grease_pencil_modifiers):
continue continue
mods = [] mods = []

View File

@ -119,11 +119,11 @@ class GPTB_OT_batch_flat_reproject(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
for o in context.selected_objects: for o in context.selected_objects:
if o.type != 'GPENCIL' or not o.select_get(): if o.type != 'GREASEPENCIL' or not o.select_get():
continue continue
batch_flat_reproject(o) batch_flat_reproject(o)

View File

@ -135,7 +135,7 @@ class GPTB_OT_go_to_object(bpy.types.Operator):
bpy.ops.object.mode_set(mode='POSE', toggle=False) bpy.ops.object.mode_set(mode='POSE', toggle=False)
self.report({'INFO'}, f'Back to pose mode, {obj.name}') self.report({'INFO'}, f'Back to pose mode, {obj.name}')
elif obj.type == 'GPENCIL': elif obj.type == 'GREASEPENCIL':
bpy.ops.object.mode_set(mode='PAINT_GPENCIL', toggle=False) bpy.ops.object.mode_set(mode='PAINT_GPENCIL', toggle=False)
else: else:

View File

@ -79,7 +79,7 @@ class GPTB_OT_rename_data_from_obj(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
if not self.rename_all: if not self.rename_all:
@ -93,7 +93,7 @@ class GPTB_OT_rename_data_from_obj(Operator):
else: else:
oblist = [] oblist = []
for o in context.scene.objects: for o in context.scene.objects:
if o.type == 'GPENCIL': if o.type == 'GREASEPENCIL':
if o.name == o.data.name: if o.name == o.data.name:
continue continue
oblist.append(f'{o.data.name} -> {o.name}') oblist.append(f'{o.data.name} -> {o.name}')
@ -250,7 +250,7 @@ class GPTB_OT_draw_cam(Operator):
drawcam.parent = act drawcam.parent = act
vec = Vector((0,1,0)) vec = Vector((0,1,0))
if act.type == 'GPENCIL': if act.type == 'GREASEPENCIL':
#change vector according to alignement #change vector according to alignement
vec = get_gp_alignement_vector(context) vec = get_gp_alignement_vector(context)
@ -427,15 +427,15 @@ class GPTB_OT_toggle_mute_animation(Operator):
pool = context.scene.objects pool = context.scene.objects
for o in pool: for o in pool:
if self.mode == 'GPENCIL' and o.type != 'GPENCIL': if self.mode == 'GREASEPENCIL' and o.type != 'GREASEPENCIL':
continue continue
if self.mode == 'OBJECT' and o.type in ('GPENCIL', 'CAMERA'): if self.mode == 'OBJECT' and o.type in ('GREASEPENCIL', 'CAMERA'):
continue continue
if self.mode == 'CAMERA' and o.type != 'CAMERA': if self.mode == 'CAMERA' and o.type != 'CAMERA':
continue continue
# mute attribute animation for GP and cameras # mute attribute animation for GP and cameras
if o.type in ('GPENCIL', 'CAMERA') and o.data.animation_data: if o.type in ('GREASEPENCIL', 'CAMERA') and o.data.animation_data:
gp_act = o.data.animation_data.action gp_act = o.data.animation_data.action
if gp_act: if gp_act:
print(f'\n---{o.name} data:') print(f'\n---{o.name} data:')
@ -473,7 +473,7 @@ class GPTB_OT_toggle_hide_gp_modifier(Operator):
else: else:
pool = context.scene.objects pool = context.scene.objects
for o in pool: for o in pool:
if o.type != 'GPENCIL': if o.type != 'GREASEPENCIL':
continue continue
for m in o.grease_pencil_modifiers: for m in o.grease_pencil_modifiers:
# skip modifier that are not visible in render # skip modifier that are not visible in render
@ -506,12 +506,12 @@ class GPTB_OT_list_disabled_anims(Operator):
pool = context.scene.objects pool = context.scene.objects
for o in pool: for o in pool:
# if self.skip_gp and o.type == 'GPENCIL': # if self.skip_gp and o.type == 'GREASEPENCIL':
# continue # continue
# if self.skip_obj and o.type != 'GPENCIL': # if self.skip_obj and o.type != 'GREASEPENCIL':
# continue # continue
if o.type == 'GPENCIL': if o.type == 'GREASEPENCIL':
if o.data.animation_data: if o.data.animation_data:
gp_act = o.data.animation_data.action gp_act = o.data.animation_data.action
if gp_act: if gp_act:
@ -611,7 +611,7 @@ class GPTB_OT_clear_active_frame(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
obj = context.object obj = context.object
@ -644,7 +644,7 @@ class GPTB_OT_check_canvas_alignement(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
# if lock_axis is 'VIEW' then the draw axis is always aligned # if lock_axis is 'VIEW' then the draw axis is always aligned
return context.object and context.object.type == 'GPENCIL'# and context.scene.tool_settings.gpencil_sculpt.lock_axis != 'VIEW' return context.object and context.object.type == 'GREASEPENCIL'# and context.scene.tool_settings.gpencil_sculpt.lock_axis != 'VIEW'
def execute(self, context): def execute(self, context):
if context.scene.tool_settings.gpencil_sculpt.lock_axis == 'VIEW': if context.scene.tool_settings.gpencil_sculpt.lock_axis == 'VIEW':
@ -673,7 +673,7 @@ class GPTB_OT_step_select_frames(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
start : bpy.props.IntProperty(name='Start Frame', start : bpy.props.IntProperty(name='Start Frame',
description='Start frame of the step animation', description='Start frame of the step animation',

View File

@ -40,8 +40,8 @@ class GPTB_OT_duplicate_send_to_layer(Operator) :
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL'\ return context.object and context.object.type == 'GREASEPENCIL'\
and context.space_data.bl_rna.identifier == 'SpaceDopeSheetEditor' and context.space_data.ui_mode == 'GPENCIL' and context.space_data.bl_rna.identifier == 'SpaceDopeSheetEditor' and context.space_data.ui_mode == 'GREASEPENCIL'
# history : bpy.props.StringProperty(default='', options={'SKIP_SAVE'}) # need to have a variable to store (to get it in self) # history : bpy.props.StringProperty(default='', options={'SKIP_SAVE'}) # need to have a variable to store (to get it in self)
@ -131,7 +131,7 @@ def unregister_keymaps():
def menu_duplicate_and_send_to_layer(self, context): def menu_duplicate_and_send_to_layer(self, context):
if context.space_data.ui_mode == 'GPENCIL': if context.space_data.ui_mode == 'GREASEPENCIL':
self.layout.operator_context = 'INVOKE_REGION_WIN' self.layout.operator_context = 'INVOKE_REGION_WIN'
self.layout.operator('gp.duplicate_send_to_layer', text='Move Keys To Layer').delete_source = True self.layout.operator('gp.duplicate_send_to_layer', text='Move Keys To Layer').delete_source = True
self.layout.operator('gp.duplicate_send_to_layer', text='Copy Keys To Layer') self.layout.operator('gp.duplicate_send_to_layer', text='Copy Keys To Layer')

View File

@ -10,7 +10,7 @@ class GPTB_OT_jump_gp_keyframe(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
next : BoolProperty( next : BoolProperty(
name="Next GP keyframe", description="Go to next active GP keyframe", name="Next GP keyframe", description="Go to next active GP keyframe",

View File

@ -261,9 +261,9 @@ def build_layers_targets_from_dopesheet(context):
if dopeset.show_only_selected: if dopeset.show_only_selected:
pool = [o for o in context.selected_objects if o.type == 'GPENCIL'] pool = [o for o in context.selected_objects if o.type == 'GREASEPENCIL']
else: else:
pool = [o for o in context.scene.objects if o.type == 'GPENCIL'] pool = [o for o in context.scene.objects if o.type == 'GREASEPENCIL']
if not dopeset.show_hidden: if not dopeset.show_hidden:
pool = [o for o in pool if o.visible_get()] pool = [o for o in pool if o.visible_get()]
@ -292,7 +292,7 @@ class GPTB_OT_select_set_same_prefix(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
mode : EnumProperty(default='SELECT', options={'SKIP_SAVE'}, mode : EnumProperty(default='SELECT', options={'SKIP_SAVE'},
items=( items=(
@ -380,7 +380,7 @@ class GPTB_OT_select_set_same_color(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
mode : EnumProperty(default='SELECT', options={'SKIP_SAVE'}, mode : EnumProperty(default='SELECT', options={'SKIP_SAVE'},
items=( items=(
@ -507,7 +507,7 @@ class GPTB_OT_rename_gp_layer(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
find: StringProperty(name="Find", description="Name to replace", default="", maxlen=0, options={'ANIMATABLE'}, subtype='NONE') find: StringProperty(name="Find", description="Name to replace", default="", maxlen=0, options={'ANIMATABLE'}, subtype='NONE')
replace: StringProperty(name="Repl", description="New name placed", default="", maxlen=0, options={'ANIMATABLE'}, subtype='NONE') replace: StringProperty(name="Repl", description="New name placed", default="", maxlen=0, options={'ANIMATABLE'}, subtype='NONE')
@ -633,7 +633,7 @@ def gpencil_dopesheet_header(self, context):
'''to append in DOPESHEET_HT_header''' '''to append in DOPESHEET_HT_header'''
layout = self.layout layout = self.layout
st = context.space_data st = context.space_data
if st.mode != 'GPENCIL': if st.mode != 'GREASEPENCIL':
return return
row = layout.row(align=True) row = layout.row(align=True)
@ -653,7 +653,7 @@ def gpencil_layer_dropdown_menu(self, context):
def obj_layer_name_callback(): def obj_layer_name_callback():
'''assign layer name properties so user an tweak it''' '''assign layer name properties so user an tweak it'''
ob = bpy.context.object ob = bpy.context.object
if not ob or ob.type != 'GPENCIL': if not ob or ob.type != 'GREASEPENCIL':
return return
if not ob.data.layers.active: if not ob.data.layers.active:
return return
@ -736,7 +736,7 @@ class GPTB_OT_add_gp_layer_with_rename(Operator):
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
add_layer(context) add_layer(context)
@ -750,7 +750,7 @@ class GPTB_OT_add_gp_layer(Operator):
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
add_layer(context) add_layer(context)

View File

@ -14,7 +14,7 @@ class GP_OT_pick_closest_layer(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' and context.mode == 'PAINT_GPENCIL' return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL'
stroke_filter : bpy.props.EnumProperty(name='Target', stroke_filter : bpy.props.EnumProperty(name='Target',
default='STROKE', default='STROKE',

View File

@ -39,7 +39,7 @@ class GPTB_OT_move_material_to_layer(Operator) :
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def invoke(self, context, event): def invoke(self, context, event):
if self.layer_name: if self.layer_name:
@ -82,7 +82,7 @@ class GPTB_OT_move_material_to_layer(Operator) :
return {'CANCELLED'} return {'CANCELLED'}
## Active + selection ## Active + selection
pool = [o for o in bpy.context.selected_objects if o.type == 'GPENCIL'] pool = [o for o in bpy.context.selected_objects if o.type == 'GREASEPENCIL']
if not context.object in pool: if not context.object in pool:
pool.append(context.object) pool.append(context.object)
@ -165,7 +165,7 @@ class GPTB_OT_move_material_to_layer(Operator) :
# def menu_duplicate_and_send_to_layer(self, context): # def menu_duplicate_and_send_to_layer(self, context):
# if context.space_data.ui_mode == 'GPENCIL': # if context.space_data.ui_mode == 'GREASEPENCIL':
# self.layout.operator_context = 'INVOKE_REGION_WIN' # self.layout.operator_context = 'INVOKE_REGION_WIN'
# self.layout.operator('gp.duplicate_send_to_layer', text='Move Keys To Layer').delete_source = True # self.layout.operator('gp.duplicate_send_to_layer', text='Move Keys To Layer').delete_source = True
# self.layout.operator('gp.duplicate_send_to_layer', text='Copy Keys To Layer') # self.layout.operator('gp.duplicate_send_to_layer', text='Copy Keys To Layer')

View File

@ -33,7 +33,7 @@ class GP_OT_pick_closest_material(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' and context.mode == 'PAINT_GPENCIL' return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL'
fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'})
@ -159,7 +159,7 @@ class GP_OT_pick_closest_material(Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' and context.mode == 'PAINT_GPENCIL' return context.object and context.object.type == 'GREASEPENCIL' and context.mode == 'PAINT_GPENCIL'
# fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) # fill_only : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'})
stroke_filter : bpy.props.EnumProperty(default='FILL', stroke_filter : bpy.props.EnumProperty(default='FILL',

View File

@ -42,7 +42,7 @@ class GPTB_OT_load_default_palette(bpy.types.Operator):
# path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="") # path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="")
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
# Start Clean (delete unuesed sh*t) # Start Clean (delete unuesed sh*t)
@ -82,7 +82,7 @@ class GPTB_OT_load_palette(bpy.types.Operator, ImportHelper):
# path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="") # path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="")
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
filename_ext = '.json' filename_ext = '.json'
@ -110,7 +110,7 @@ class GPTB_OT_save_palette(bpy.types.Operator, ExportHelper):
# path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="") # path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="")
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
filter_glob: bpy.props.StringProperty(default='*.json', options={'HIDDEN'})#*.jpg;*.jpeg;*.png;*.tif;*.tiff;*.bmp filter_glob: bpy.props.StringProperty(default='*.json', options={'HIDDEN'})#*.jpg;*.jpeg;*.png;*.tif;*.tiff;*.bmp
@ -169,7 +169,7 @@ def load_blend_palette(context, filepath):
print(f'-- import palette from : {filepath} --') print(f'-- import palette from : {filepath} --')
for ob in context.selected_objects: for ob in context.selected_objects:
if ob.type != 'GPENCIL': if ob.type != 'GREASEPENCIL':
print(f'{ob.name} not a GP object') print(f'{ob.name} not a GP object')
continue continue
@ -224,7 +224,7 @@ class GPTB_OT_load_blend_palette(bpy.types.Operator, ImportHelper):
# path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="") # path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="")
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
filename_ext = '.blend' filename_ext = '.blend'
@ -252,7 +252,7 @@ class GPTB_OT_copy_active_to_selected_palette(bpy.types.Operator):
# path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="") # path_to_pal : bpy.props.StringProperty(name="paht to palette", description="path to the palette", default="")
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def execute(self, context): def execute(self, context):
ob = context.object ob = context.object
@ -260,7 +260,7 @@ class GPTB_OT_copy_active_to_selected_palette(bpy.types.Operator):
self.report({'ERROR'}, 'No materials to transfer') self.report({'ERROR'}, 'No materials to transfer')
return {"CANCELLED"} return {"CANCELLED"}
selection = [o for o in context.selected_objects if o.type == 'GPENCIL' and o != ob] selection = [o for o in context.selected_objects if o.type == 'GREASEPENCIL' and o != ob]
if not selection: if not selection:
self.report({'ERROR'}, 'Need to have other Grease pencil objects selected to receive active object materials') self.report({'ERROR'}, 'Need to have other Grease pencil objects selected to receive active object materials')
@ -313,7 +313,7 @@ class GPTB_OT_clean_material_stack(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
def invoke(self, context, event): def invoke(self, context, event):
self.ob = context.object self.ob = context.object
@ -354,7 +354,7 @@ class GPTB_OT_clean_material_stack(bpy.types.Operator):
import re import re
diff_ct = 0 diff_ct = 0
todel = [] todel = []
if ob.type != 'GPENCIL': if ob.type != 'GREASEPENCIL':
return return
if not hasattr(ob, 'material_slots'): if not hasattr(ob, 'material_slots'):
return return

View File

@ -45,7 +45,7 @@ class GPTB_OT_import_obj_palette(Operator):
def execute(self, context): def execute(self, context):
## get targets ## get targets
selection = [o for o in context.selected_objects if o.type == 'GPENCIL'] selection = [o for o in context.selected_objects if o.type == 'GREASEPENCIL']
if not selection: if not selection:
self.report({'ERROR'}, 'Need to have at least one GP object selected in scene') self.report({'ERROR'}, 'Need to have at least one GP object selected in scene')
return {"CANCELLED"} return {"CANCELLED"}
@ -98,7 +98,7 @@ class GPTB_OT_import_obj_palette(Operator):
return {"CANCELLED"} return {"CANCELLED"}
for i in range(len(linked_objs))[::-1]: # reversed(range(len(l))) / range(len(l))[::-1] for i in range(len(linked_objs))[::-1]: # reversed(range(len(l))) / range(len(l))[::-1]
if linked_objs[i].type != 'GPENCIL': if linked_objs[i].type != 'GREASEPENCIL':
print(f'{linked_objs[i].name} type is "{linked_objs[i].type}"') print(f'{linked_objs[i].name} type is "{linked_objs[i].type}"')
bpy.data.objects.remove(linked_objs.pop(i)) bpy.data.objects.remove(linked_objs.pop(i))

View File

@ -267,7 +267,7 @@ class GPTB_OT_realign(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
reproject : bpy.props.BoolProperty( reproject : bpy.props.BoolProperty(
name='Reproject', default=True, name='Reproject', default=True,
@ -365,7 +365,7 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GREASEPENCIL'
all_strokes : bpy.props.BoolProperty( all_strokes : bpy.props.BoolProperty(
name='All Strokes', default=True, name='All Strokes', default=True,

View File

@ -144,7 +144,7 @@ class GPTB_PT_sidebar_panel(Panel):
col.prop(context.scene.gptoolprops, 'keyframe_type', text='Jump On') # Keyframe Jump col.prop(context.scene.gptoolprops, 'keyframe_type', text='Jump On') # Keyframe Jump
# col.prop(context.space_data.overlay, 'use_gpencil_onion_skin') # not often used # col.prop(context.space_data.overlay, 'use_gpencil_onion_skin') # not often used
if context.object and context.object.type == 'GPENCIL': if context.object and context.object.type == 'GREASEPENCIL':
# col.prop(context.object.data, 'use_autolock_layers') # not often used # col.prop(context.object.data, 'use_autolock_layers') # not often used
col.prop(context.object, 'show_in_front') # text='In Front' col.prop(context.object, 'show_in_front') # text='In Front'
@ -191,23 +191,23 @@ class GPTB_PT_anim_manager(Panel):
# import time # import time
# t0 = time.perf_counter() # t0 = time.perf_counter()
# objs = [o for o in context.scene.objects if o.type not in ('GPENCIL', 'CAMERA')] # objs = [o for o in context.scene.objects if o.type not in ('GREASEPENCIL', 'CAMERA')]
# gps = [o for o in context.scene.objects if o.type == 'GPENCIL'] # gps = [o for o in context.scene.objects if o.type == 'GREASEPENCIL']
# cams = [o for o in context.scene.objects if o.type == 'CAMERA'] # cams = [o for o in context.scene.objects if o.type == 'CAMERA']
objs = [] objs = []
gps = [] gps = []
cams = [] cams = []
for o in context.scene.objects: for o in context.scene.objects:
if o.type not in ('GPENCIL', 'CAMERA'): if o.type not in ('GREASEPENCIL', 'CAMERA'):
objs.append(o) objs.append(o)
elif o.type == 'GPENCIL': elif o.type == 'GREASEPENCIL':
gps.append(o) gps.append(o)
elif o.type == 'CAMERA': elif o.type == 'CAMERA':
cams.append(o) cams.append(o)
# print(f'{time.perf_counter() - t0:.8f}s') # print(f'{time.perf_counter() - t0:.8f}s')
return {'OBJECT': objs, 'GPENCIL': gps, 'CAMERA': cams} return {'OBJECT': objs, 'GREASEPENCIL': gps, 'CAMERA': cams}
def draw(self, context): def draw(self, context):
@ -221,7 +221,7 @@ class GPTB_PT_anim_manager(Panel):
col.operator('gp.list_disabled_anims') col.operator('gp.list_disabled_anims')
## Show Enable / Disable anims ## Show Enable / Disable anims
for cat, cat_type in [('Obj anims:', 'OBJECT'), ('Cam anims:', 'CAMERA'), ('Gp anims:', 'GPENCIL')]: for cat, cat_type in [('Obj anims:', 'OBJECT'), ('Cam anims:', 'CAMERA'), ('Gp anims:', 'GREASEPENCIL')]:
on_icon, off_icon = anim_status(obj_types[cat_type]) on_icon, off_icon = anim_status(obj_types[cat_type])
subcol = col.column() subcol = col.column()
@ -242,7 +242,7 @@ class GPTB_PT_anim_manager(Panel):
row = subcol.row(align=True) row = subcol.row(align=True)
row.label(text='Gp modifiers:') row.label(text='Gp modifiers:')
on_icon, off_icon = gp_modifier_status(obj_types['GPENCIL']) on_icon, off_icon = gp_modifier_status(obj_types['GREASEPENCIL'])
# subcol.alert = off_icon == 'LAYER_ACTIVE' # Turn red # subcol.alert = off_icon == 'LAYER_ACTIVE' # Turn red
row.operator('gp.toggle_hide_gp_modifier', text='ON', icon=on_icon).show = True row.operator('gp.toggle_hide_gp_modifier', text='ON', icon=on_icon).show = True
row.operator('gp.toggle_hide_gp_modifier', text='OFF', icon=off_icon).show = False row.operator('gp.toggle_hide_gp_modifier', text='OFF', icon=off_icon).show = False
@ -734,7 +734,7 @@ def interpolate_header_ui(self, context):
layout = self.layout layout = self.layout
obj = context.active_object obj = context.active_object
if obj and obj.type == 'GPENCIL' and context.gpencil_data: if obj and obj.type == 'GREASEPENCIL' and context.gpencil_data:
gpd = context.gpencil_data gpd = context.gpencil_data
else: else:
return return

View File

@ -4,8 +4,8 @@ bl_info = {
"name": "GP toolbox", "name": "GP toolbox",
"description": "Tool set for Grease Pencil in animation production", "description": "Tool set for Grease Pencil in animation production",
"author": "Samuel Bernou, Christophe Seux", "author": "Samuel Bernou, Christophe Seux",
"version": (3, 3, 0), "version": (4, 0, 0),
"blender": (4, 0, 0), "blender": (4, 3, 0),
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
"warning": "", "warning": "",
"doc_url": "https://git.autourdeminuit.com/autour_de_minuit/gp_toolbox", "doc_url": "https://git.autourdeminuit.com/autour_de_minuit/gp_toolbox",

View File

@ -21,7 +21,7 @@ def update_layer_name(self, context):
if not self.layer_name: if not self.layer_name:
# never replace by nothing (since there should be prefix/suffix) # never replace by nothing (since there should be prefix/suffix)
return return
if not context.object or context.object.type != 'GPENCIL': if not context.object or context.object.type != 'GREASEPENCIL':
return return
if not context.object.data.layers.active: if not context.object.data.layers.active:
return return

View File

@ -372,24 +372,24 @@ def create_gp_palette(gp_data_block,info) :
def get_gp_objects(selection=True): def get_gp_objects(selection=True):
'''return selected objects or only the active one''' '''return selected objects or only the active one'''
if not bpy.context.active_object or bpy.context.active_object.type != 'GPENCIL': if not bpy.context.active_object or bpy.context.active_object.type != 'GREASEPENCIL':
print('No active GP object') print('No active GP object')
return [] return []
active = bpy.context.active_object active = bpy.context.active_object
if selection: if selection:
selection = [o for o in bpy.context.selected_objects if o.type == 'GPENCIL'] selection = [o for o in bpy.context.selected_objects if o.type == 'GREASEPENCIL']
if not active in selection: if not active in selection:
selection += [active] selection += [active]
return selection return selection
if bpy.context.active_object and bpy.context.active_object.type == 'GPENCIL': if bpy.context.active_object and bpy.context.active_object.type == 'GREASEPENCIL':
return [active] return [active]
return [] return []
def get_gp_datas(selection=True): def get_gp_datas(selection=True):
'''return selected objects or only the active one''' '''return selected objects or only the active one'''
if not bpy.context.active_object or bpy.context.active_object.type != 'GPENCIL': if not bpy.context.active_object or bpy.context.active_object.type != 'GREASEPENCIL':
print('No active GP object') print('No active GP object')
return [] return []
@ -397,15 +397,15 @@ def get_gp_datas(selection=True):
if selection: if selection:
selected = [] selected = []
for o in bpy.context.selected_objects: for o in bpy.context.selected_objects:
if o.type == 'GPENCIL': if o.type == 'GREASEPENCIL':
if o.data not in selected: if o.data not in selected:
selected.append(o.data) selected.append(o.data)
# selected = [o.data for o in bpy.context.selected_objects if o.type == 'GPENCIL'] # selected = [o.data for o in bpy.context.selected_objects if o.type == 'GREASEPENCIL']
if not active_data in selected: if not active_data in selected:
selected += [active_data] selected += [active_data]
return selected return selected
if bpy.context.active_object and bpy.context.active_object.type == 'GPENCIL': if bpy.context.active_object and bpy.context.active_object.type == 'GREASEPENCIL':
return [active_data] return [active_data]
print('EOL. No active GP object') print('EOL. No active GP object')
@ -1206,7 +1206,7 @@ def all_anim_enabled(objects) -> bool:
if fcu.mute: if fcu.mute:
return False return False
if o.type in ('GPENCIL', 'CAMERA'): if o.type in ('GREASEPENCIL', 'CAMERA'):
if o.data.animation_data and o.data.animation_data.action: if o.data.animation_data and o.data.animation_data.action:
## Check if object data attributes fcurves are muted ## Check if object data attributes fcurves are muted
for fcu in o.animation_data.action.fcurves: for fcu in o.animation_data.action.fcurves:
@ -1219,7 +1219,7 @@ def all_anim_enabled(objects) -> bool:
def all_object_modifier_enabled(objects) -> bool: def all_object_modifier_enabled(objects) -> bool:
'''Return False if one modifier of one object has GP modifier disabled in viewport but enabled in render''' '''Return False if one modifier of one object has GP modifier disabled in viewport but enabled in render'''
for o in objects: for o in objects:
if o.type != 'GPENCIL': if o.type != 'GREASEPENCIL':
continue continue
for m in o.grease_pencil_modifiers: for m in o.grease_pencil_modifiers:
if m.show_render and not m.show_viewport: if m.show_render and not m.show_viewport:
@ -1247,7 +1247,7 @@ def has_fully_enabled_anim(o):
if fcu.mute: if fcu.mute:
return False return False
if o.type in ('GPENCIL', 'CAMERA'): if o.type in ('GREASEPENCIL', 'CAMERA'):
if o.data.animation_data and o.data.animation_data.action: if o.data.animation_data and o.data.animation_data.action:
## Check if object data attributes fcurves are muted ## Check if object data attributes fcurves are muted
for fcu in o.animation_data.action.fcurves: for fcu in o.animation_data.action.fcurves:
@ -1292,7 +1292,7 @@ def anim_status(objects) -> tuple((str, str)):
on_count += 1 on_count += 1
count += 1 count += 1
if o.type in ('GPENCIL', 'CAMERA'): if o.type in ('GREASEPENCIL', 'CAMERA'):
datablock = o.data datablock = o.data
if datablock.animation_data is None: if datablock.animation_data is None:
continue continue
@ -1320,7 +1320,7 @@ def gp_modifier_status(objects) -> tuple((str, str)):
'''return icons on/off tuple''' '''return icons on/off tuple'''
on_count = off_count = count = 0 on_count = off_count = count = 0
for o in objects: for o in objects:
if o.type != 'GPENCIL': if o.type != 'GREASEPENCIL':
continue continue
## Skip hided object ## Skip hided object
if o.hide_get() and o.hide_render: if o.hide_get() and o.hide_render: