Brushstroke Tools: Initial Version #328
@ -307,6 +307,61 @@ class BSBST_OT_duplicate_brushstrokes(bpy.types.Operator):
|
|||||||
bpy.ops.object.duplicate_move()
|
bpy.ops.object.duplicate_move()
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class BSBST_OT_copy_brushstrokes(bpy.types.Operator):
|
||||||
|
"""
|
||||||
|
Copy the active context brushstrokes to the selected surface objects
|
||||||
|
"""
|
||||||
|
bl_idname = "brushstroke_tools.copy_brushstrokes"
|
||||||
|
bl_label = "Copy Brushstrokes to Selected"
|
||||||
|
bl_description = "Copy the active context brushstrokes to the selected surface objects"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
copy_all: bpy.props.BoolProperty(default=False)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
return bool(settings.context_brushstrokes)
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
|
||||||
|
surface_objects = [ob for ob in context.selected_objects if ob.type=='MESH' and not utils.is_brushstrokes_object(ob)]
|
||||||
|
if not surface_objects:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
print(surface_objects)
|
||||||
|
|
||||||
|
if self.copy_all:
|
||||||
|
bs_objects = [bpy.data.objects.get(bs.name) for bs in settings.context]
|
||||||
|
bs_objects = [bs for bs in bs_objects if bs]
|
||||||
|
else:
|
||||||
|
bs_objects = [utils.get_active_context_brushstrokes_object(context)]
|
||||||
|
if not bs_objects:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
|
for surface_object in surface_objects:
|
||||||
|
for bs_ob in bs_objects:
|
||||||
|
flow_object = utils.get_flow_object(bs_ob)
|
||||||
|
|
||||||
|
bpy.context.view_layer.objects.active = bs_ob
|
||||||
|
for ob in bpy.data.objects:
|
||||||
|
ob.select_set(False)
|
||||||
|
bs_ob.select_set(True)
|
||||||
|
flow_object.select_set(True)
|
||||||
|
bpy.ops.object.duplicate_move()
|
||||||
|
|
||||||
|
# remap surface pointers and context linked data
|
||||||
|
bs_ob.parent = surface_object
|
||||||
|
utils.set_surface_object(bs_ob, surface_object)
|
||||||
|
# TODO
|
||||||
|
|
||||||
|
# enable rest position
|
||||||
|
surface_object.add_rest_position_attribute = True
|
||||||
|
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
class BSBST_OT_select_surface(bpy.types.Operator):
|
class BSBST_OT_select_surface(bpy.types.Operator):
|
||||||
"""
|
"""
|
||||||
@ -649,6 +704,7 @@ classes = [
|
|||||||
BSBST_OT_edit_brushstrokes,
|
BSBST_OT_edit_brushstrokes,
|
||||||
BSBST_OT_delete_brushstrokes,
|
BSBST_OT_delete_brushstrokes,
|
||||||
BSBST_OT_duplicate_brushstrokes,
|
BSBST_OT_duplicate_brushstrokes,
|
||||||
|
BSBST_OT_copy_brushstrokes,
|
||||||
BSBST_OT_select_surface,
|
BSBST_OT_select_surface,
|
||||||
BSBST_OT_init_preset,
|
BSBST_OT_init_preset,
|
||||||
BSBST_OT_make_preset,
|
BSBST_OT_make_preset,
|
||||||
|
@ -282,6 +282,10 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
|
|||||||
column = row.column(align=True)
|
column = row.column(align=True)
|
||||||
column.operator('brushstroke_tools.delete_brushstrokes', text='', icon='TRASH')
|
column.operator('brushstroke_tools.delete_brushstrokes', text='', icon='TRASH')
|
||||||
column.operator('brushstroke_tools.duplicate_brushstrokes', text='', icon='DUPLICATE')
|
column.operator('brushstroke_tools.duplicate_brushstrokes', text='', icon='DUPLICATE')
|
||||||
|
column.operator('brushstroke_tools.copy_brushstrokes', text='', icon='DUPLICATE')
|
||||||
|
op = column.operator('brushstroke_tools.copy_brushstrokes', text='', icon='DUPLICATE')
|
||||||
|
op.copy_all = True
|
||||||
|
# TODO make nice
|
||||||
|
|
||||||
row = style_panel.row()
|
row = style_panel.row()
|
||||||
row_edit = row.row(align=True)
|
row_edit = row.row(align=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user