Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
3 changed files with 11 additions and 27 deletions
Showing only changes of commit 47d0dc77eb - Show all commits

View File

@ -18,12 +18,8 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
object = context.object surface_object = utils.get_active_context_surface_object(context)
if not object: return bool(surface_object)
return False
if not object in context.selected_objects:
return False
return object.type in ['MESH', 'CURVE', 'CURVES', 'GREASEPENCIL']
def new_brushstrokes_object(self, context, name): def new_brushstrokes_object(self, context, name):
settings = context.scene.BSBST_settings settings = context.scene.BSBST_settings
@ -97,11 +93,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
utils.ensure_resources() utils.ensure_resources()
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
context_object = context.object surface_object = utils.get_active_context_surface_object(context)
surf_ob = utils.get_surface_object(context_object)
if surf_ob:
context_object = surf_ob
surface_object = context_object if context.object in context.selected_objects else None
flow_object = None flow_object = None
if not surface_object.data.uv_layers.active: if not surface_object.data.uv_layers.active:

View File

@ -310,25 +310,10 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
layout = self.layout layout = self.layout
settings = context.scene.BSBST_settings settings = context.scene.BSBST_settings
surface_object = None surface_object = utils.get_active_context_surface_object(context)
if settings.context_brushstrokes:
active_brushstrokes_object = bpy.data.objects.get(settings.context_brushstrokes[settings.active_context_brushstrokes_index].name)
if active_brushstrokes_object:
if 'BSBST_surface_object' in active_brushstrokes_object.keys():
surface_object = active_brushstrokes_object['BSBST_surface_object']
else:
surface_object = context.object
else:
surface_object = context.object
else:
surface_object = context.object
surface_row = layout.row() surface_row = layout.row()
if surface_object: if surface_object:
valid_surface = surface_object.type in ['MESH'] and (surface_object in context.selected_objects or context.object in context.selected_objects)
else:
valid_surface = False
if valid_surface:
surface_row.label(text=f'{surface_object.name}', icon='OUTLINER_OB_SURFACE') surface_row.label(text=f'{surface_object.name}', icon='OUTLINER_OB_SURFACE')
else: else:
surface_row.alert = True surface_row.alert = True

View File

@ -510,6 +510,13 @@ def get_active_context_brushstrokes_object(context):
bs_ob = bpy.data.objects.get(bs.name) bs_ob = bpy.data.objects.get(bs.name)
return bs_ob return bs_ob
def get_active_context_surface_object(context):
bs_ob = get_active_context_brushstrokes_object(context)
if bs_ob:
return get_surface_object(bs_ob)
if context.object.type == 'MESH':
return context.object
def flow_name(name): def flow_name(name):
return f'{name}-FLOW' return f'{name}-FLOW'