Fix modifiers access
parent
f5c20a3499
commit
7430bca02f
|
@ -475,7 +475,7 @@ class GPTB_OT_toggle_hide_gp_modifier(Operator):
|
|||
for o in pool:
|
||||
if o.type != 'GREASEPENCIL':
|
||||
continue
|
||||
for m in o.modifier:
|
||||
for m in o.modifiers:
|
||||
# skip modifier that are not visible in render
|
||||
if not m.show_render:
|
||||
continue
|
||||
|
|
|
@ -78,7 +78,7 @@ def layer_name_build(layer, prefix='', desc='', suffix=''):
|
|||
# maybe a more elegant way exists to find all objects users ?
|
||||
|
||||
# update Gpencil modifier targets
|
||||
for mod in ob_user.modifier:
|
||||
for mod in ob_user.modifiers:
|
||||
if not hasattr(mod, 'layer_filter'):
|
||||
continue
|
||||
if mod.layer_filter == old:
|
||||
|
@ -675,14 +675,28 @@ def obj_layer_name_callback():
|
|||
# print('inc:', res.group('inc'))
|
||||
bpy.context.scene.gptoolprops['layer_name'] = res.group('name')
|
||||
|
||||
## old gpv2
|
||||
# def subscribe_layer_change():
|
||||
# subscribe_to = (bpy.types.GreasePencilLayers, "active_index")
|
||||
# bpy.msgbus.subscribe_rna(
|
||||
# key=subscribe_to,
|
||||
# # owner of msgbus subcribe (for clearing later)
|
||||
# # owner=handle,
|
||||
# owner=bpy.types.GreasePencil, # <-- can attach to an ID during all it's lifetime...
|
||||
# # Args passed to callback function (tuple)
|
||||
# args=(),
|
||||
# # Callback function for property update
|
||||
# notify=obj_layer_name_callback,
|
||||
# options={'PERSISTENT'},
|
||||
# )
|
||||
|
||||
def subscribe_layer_change():
|
||||
subscribe_to = (bpy.types.GreasePencilLayers, "active_index")
|
||||
subscribe_to = (bpy.types.GreasePencilv3Layers, "active")
|
||||
bpy.msgbus.subscribe_rna(
|
||||
key=subscribe_to,
|
||||
# owner of msgbus subcribe (for clearing later)
|
||||
# owner=handle,
|
||||
owner=bpy.types.GreasePencil, # <-- can attach to an ID during all it's lifetime...
|
||||
owner=bpy.types.GreasePencilv3, # <-- can attach to an ID during all it's lifetime...
|
||||
# Args passed to callback function (tuple)
|
||||
args=(),
|
||||
# Callback function for property update
|
||||
|
@ -690,6 +704,7 @@ def subscribe_layer_change():
|
|||
options={'PERSISTENT'},
|
||||
)
|
||||
|
||||
|
||||
@persistent
|
||||
def subscribe_layer_change_handler(dummy):
|
||||
subscribe_layer_change()
|
||||
|
@ -723,7 +738,7 @@ class GPTB_PT_layer_name_ui(bpy.types.Panel):
|
|||
row = layout.row()
|
||||
row.activate_init = True
|
||||
row.label(icon='OUTLINER_DATA_GP_LAYER')
|
||||
row.prop(context.object.data.layers.active, 'info', text='')
|
||||
row.prop(context.object.data.layers.active, 'name', text='')
|
||||
|
||||
def add_layer(context):
|
||||
bpy.ops.gpencil.layer_add()
|
||||
|
@ -836,5 +851,6 @@ def unregister():
|
|||
for cls in reversed(classes):
|
||||
bpy.utils.unregister_class(cls)
|
||||
|
||||
# delete layer index trigger
|
||||
bpy.msgbus.clear_by_owner(bpy.types.GreasePencil)
|
||||
# Delete layer index trigger
|
||||
# /!\ can remove msgbus made for other functions or other addons using same owner
|
||||
bpy.msgbus.clear_by_owner(bpy.types.GreasePencilv3)
|
|
@ -26,10 +26,10 @@ class GPT_OT_layer_nav(bpy.types.Operator):
|
|||
prefs = utils.get_addon_prefs()
|
||||
if not prefs.nav_use_fade:
|
||||
if self.direction == 'DOWN':
|
||||
utils.iterate_selector(context.object.data.layers, 'active_index', -1, info_attr = 'info')
|
||||
utils.iterate_selector(context.object.data.layers, 'active_index', -1, info_attr = 'name')
|
||||
|
||||
if self.direction == 'UP':
|
||||
utils.iterate_selector(context.object.data.layers, 'active_index', 1, info_attr = 'info')
|
||||
utils.iterate_selector(context.object.data.layers, 'active_index', 1, info_attr = 'name')
|
||||
return {'FINISHED'}
|
||||
|
||||
## get up and down keys for use in modal
|
||||
|
@ -91,12 +91,12 @@ class GPT_OT_layer_nav(bpy.types.Operator):
|
|||
context.space_data.overlay.gpencil_fade_layer = fade
|
||||
|
||||
if self.direction == 'DOWN' or ((event.type in self.down_keys) and event.value == 'PRESS'):
|
||||
_val = utils.iterate_selector(context.object.data.layers, 'active_index', -1, info_attr = 'info')
|
||||
_val = utils.iterate_selector(context.object.data.layers, 'active_index', -1, info_attr = 'name')
|
||||
trigger = True
|
||||
|
||||
if self.direction == 'UP' or ((event.type in self.up_keys) and event.value == 'PRESS'):
|
||||
_val = utils.iterate_selector(context.object.data.layers, 'active_index', 1, info_attr = 'info')
|
||||
# utils.iterate_selector(bpy.context.scene.grease_pencil.layers, 'active_index', 1, info_attr = 'info')#layers
|
||||
_val = utils.iterate_selector(context.object.data.layers, 'active_index', 1, info_attr = 'name')
|
||||
# utils.iterate_selector(bpy.context.scene.grease_pencil.layers, 'active_index', 1, info_attr = 'name')#layers
|
||||
trigger = True
|
||||
|
||||
if trigger:
|
||||
|
|
4
utils.py
4
utils.py
|
@ -1396,7 +1396,7 @@ def all_object_modifier_enabled(objects) -> bool:
|
|||
for o in objects:
|
||||
if o.type != 'GREASEPENCIL':
|
||||
continue
|
||||
for m in o.modifier:
|
||||
for m in o.modifiers:
|
||||
if m.show_render and not m.show_viewport:
|
||||
return False
|
||||
|
||||
|
@ -1500,7 +1500,7 @@ def gp_modifier_status(objects) -> tuple((str, str)):
|
|||
## Skip hided object
|
||||
if o.hide_get() and o.hide_render:
|
||||
continue
|
||||
for m in o.modifier:
|
||||
for m in o.modifiers:
|
||||
if m.show_render and not m.show_viewport:
|
||||
off_count += 1
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue