Brushstroke Tools: Initial Version #328
@ -1,6 +1,6 @@
|
||||
import bpy
|
||||
import random
|
||||
from . import utils
|
||||
from . import utils, settings
|
||||
import mathutils
|
||||
|
||||
class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
||||
@ -493,6 +493,7 @@ class BSBST_OT_copy_flow(bpy.types.Operator):
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
source_bs: bpy.props.StringProperty(name="Brushstroke Layers")
|
||||
bs_list: bpy.props.CollectionProperty(type=settings.BSBST_context_brushstrokes)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
@ -500,23 +501,60 @@ class BSBST_OT_copy_flow(bpy.types.Operator):
|
||||
return bool(settings.context_brushstrokes)
|
||||
|
||||
def execute(self, context):
|
||||
settings = context.scene.BSBST_settings
|
||||
bs_ob = utils.get_active_context_brushstrokes_object(context)
|
||||
flow_ob_old = utils.get_flow_object(bs_ob)
|
||||
if not bs_ob:
|
||||
return {"CANCELLED"}
|
||||
|
||||
# get target object
|
||||
# get source
|
||||
|
||||
source_ob = bpy.data.objects.get(self.source_bs)
|
||||
flow_ob = utils.get_flow_object(source_ob)
|
||||
if not source_ob or not flow_ob:
|
||||
return {"CANCELLED"}
|
||||
|
||||
# set flow object
|
||||
# delete old flow
|
||||
|
||||
utils.set_flow_object(bs_ob, flow_ob)
|
||||
|
||||
# delete old flow if unused necessary
|
||||
|
||||
if not flow_ob_old:
|
||||
return {"FINISHED"}
|
||||
for bs in self.bs_list:
|
||||
flow_ob = utils.get_flow_object(source_ob)
|
||||
if not flow_ob:
|
||||
continue
|
||||
if flow_ob.name == flow_ob_old.name:
|
||||
return {"FINISHED"}
|
||||
|
||||
bpy.data.objects.remove(flow_ob_old)
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
def draw(self, context):
|
||||
settings = context.scene.BSBST_settings
|
||||
layout = self.layout
|
||||
layout.prop_search(self, 'source_bs', settings, 'context_brushstrokes')
|
||||
layout.prop_search(self, 'source_bs', self, 'bs_list', icon='OUTLINER_OB_FORCE_FIELD')
|
||||
|
||||
def invoke(self, context, event):
|
||||
settings = context.scene.BSBST_settings
|
||||
|
||||
bs_ob = utils.get_active_context_brushstrokes_object(context)
|
||||
|
||||
for i in range(len(self.bs_list)):
|
||||
self.bs_list.remove(0)
|
||||
|
||||
for bs in settings.context_brushstrokes:
|
||||
if not bs.method=='SURFACE_FILL':
|
||||
continue
|
||||
if bs.name==bs_ob.name:
|
||||
continue
|
||||
bs_new = self.bs_list.add()
|
||||
bs_new.name = bs.name
|
||||
bs_new.hide_viewport_base = bs.hide_viewport_base
|
||||
|
||||
if self.bs_list:
|
||||
self.source_bs = self.bs_list[0].name
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
class BSBST_OT_switch_deformable(bpy.types.Operator):
|
||||
|
Loading…
Reference in New Issue
Block a user