Brushstroke Tools: Initial Version #328
@ -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:
|
||||||
|
@ -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
|
||||||
|
@ -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'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user