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
Showing only changes of commit 1de02c4d92 - Show all commits

View File

@ -1,6 +1,6 @@
import bpy import bpy
import random import random
from . import utils from . import utils, settings
import mathutils import mathutils
class BSBST_OT_new_brushstrokes(bpy.types.Operator): class BSBST_OT_new_brushstrokes(bpy.types.Operator):
@ -492,31 +492,69 @@ class BSBST_OT_copy_flow(bpy.types.Operator):
bl_description = "Copy the flow object from another brushstroke layer." bl_description = "Copy the flow object from another brushstroke layer."
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
source_bs: bpy.props.StringProperty(name="Brushstroke Layers") source_bs: bpy.props.StringProperty(name="Brushstroke Layers")
bs_list: bpy.props.CollectionProperty(type=settings.BSBST_context_brushstrokes)
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
settings = context.scene.BSBST_settings settings = context.scene.BSBST_settings
return bool(settings.context_brushstrokes) return bool(settings.context_brushstrokes)
def execute(self, context): def execute(self, context):
settings = context.scene.BSBST_settings
bs_ob = utils.get_active_context_brushstrokes_object(context) bs_ob = utils.get_active_context_brushstrokes_object(context)
flow_ob_old = utils.get_flow_object(bs_ob)
if not bs_ob: if not bs_ob:
return {"CANCELLED"} 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 # 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"} return {"FINISHED"}
def draw(self, context): def draw(self, context):
settings = context.scene.BSBST_settings
layout = self.layout 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): 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) return context.window_manager.invoke_props_dialog(self)
class BSBST_OT_switch_deformable(bpy.types.Operator): class BSBST_OT_switch_deformable(bpy.types.Operator):