Brushstroke Tools: Initial Version #328
@ -977,6 +977,24 @@ class BSBST_OT_render_setup(bpy.types.Operator):
|
|||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
return context.window_manager.invoke_props_dialog(self)
|
return context.window_manager.invoke_props_dialog(self)
|
||||||
|
|
||||||
|
class BSBST_OT_new_material(bpy.types.Operator):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
bl_idname = "brushstroke_tools.new_material"
|
||||||
|
bl_label = "New Brushstrokes Material"
|
||||||
|
bl_description = "Create new material for the current brushstrokes"
|
||||||
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
return bool(utils.context_brushstrokes(context))
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
mat = utils.import_brushstroke_material()
|
||||||
|
settings.context_material = mat
|
||||||
|
return {"FINISHED"}
|
||||||
|
|
||||||
classes = [
|
classes = [
|
||||||
BSBST_OT_new_brushstrokes,
|
BSBST_OT_new_brushstrokes,
|
||||||
BSBST_OT_edit_brushstrokes,
|
BSBST_OT_edit_brushstrokes,
|
||||||
@ -993,6 +1011,7 @@ classes = [
|
|||||||
BSBST_OT_preset_toggle_attribute,
|
BSBST_OT_preset_toggle_attribute,
|
||||||
BSBST_OT_brushstrokes_toggle_attribute,
|
BSBST_OT_brushstrokes_toggle_attribute,
|
||||||
BSBST_OT_render_setup,
|
BSBST_OT_render_setup,
|
||||||
|
BSBST_OT_new_material,
|
||||||
]
|
]
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
@ -407,8 +407,11 @@ class BSBST_PT_brushstroke_tools_panel(bpy.types.Panel):
|
|||||||
style_panel.operator("brushstroke_tools.init_preset", icon='MODIFIER')
|
style_panel.operator("brushstroke_tools.init_preset", icon='MODIFIER')
|
||||||
else:
|
else:
|
||||||
if settings.context_material:
|
if settings.context_material:
|
||||||
if getattr(settings.context_material, '["BSBST"]', False):
|
|
||||||
draw_material_settings(style_panel, settings.context_material, surface_object=surface_object)
|
draw_material_settings(style_panel, settings.context_material, surface_object=surface_object)
|
||||||
|
else:
|
||||||
|
material_row = style_panel.row(align=True)
|
||||||
|
material_row.template_ID(settings, 'context_material', new='brushstroke_tools.new_material')
|
||||||
|
|
||||||
elif settings.view_tab == 'SHAPE':
|
elif settings.view_tab == 'SHAPE':
|
||||||
if style_object:
|
if style_object:
|
||||||
for mod in style_object.modifiers:
|
for mod in style_object.modifiers:
|
||||||
|
@ -260,6 +260,20 @@ def compare_versions(v1: tuple, v2: tuple):
|
|||||||
c += 1
|
c += 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
def import_brushstroke_material():
|
||||||
|
name = 'Brushstrokes'
|
||||||
|
path = f"{get_resource_directory()}/brushstroke_tools-resources.blend"
|
||||||
|
addon_prefs = bpy.context.preferences.addons[__package__].preferences
|
||||||
|
|
||||||
|
mats_pre = set(bpy.data.materials)
|
||||||
|
with bpy.data.libraries.load(path, link=addon_prefs.import_method=='LINK', relative=addon_prefs.import_relative_path) as (data_src, data_dst):
|
||||||
|
data_dst.materials = [name]
|
||||||
|
mats_new = list(set(bpy.data.materials) - mats_pre)
|
||||||
|
if mats_new:
|
||||||
|
return mats_new[0]
|
||||||
|
else:
|
||||||
|
return bpy.data.materials.get(name)
|
||||||
|
|
||||||
def ensure_node_group(name, path):
|
def ensure_node_group(name, path):
|
||||||
ng = bpy.data.node_groups.get(name)
|
ng = bpy.data.node_groups.get(name)
|
||||||
if ng:
|
if ng:
|
||||||
|
Loading…
Reference in New Issue
Block a user