Brushstroke Tools: Initial Version #328
@ -17,6 +17,9 @@ def register():
|
||||
# Add addon asset library
|
||||
utils.register_asset_lib()
|
||||
|
||||
# Get available brush styles
|
||||
#utils.refresh_brushstroke_styles(bpy.context)
|
||||
|
||||
def unregister():
|
||||
# un-register modules
|
||||
for m in reversed(modules):
|
||||
|
Binary file not shown.
@ -4,6 +4,18 @@ import os
|
||||
|
||||
def update_resource_path(self, context):
|
||||
utils.update_asset_lib_path()
|
||||
|
||||
class BSBST_OT_refresh_brushstroke_styles(bpy.types.Operator):
|
||||
"""
|
||||
"""
|
||||
bl_idname = "brushstroke_tools.refresh_styles"
|
||||
bl_label = "Refresh Brushstroke Styles"
|
||||
bl_description = "Refresh available brushstroke styles from library."
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
utils.refresh_brushstroke_styles(context)
|
||||
return {"FINISHED"}
|
||||
class BSBST_OT_copy_resources_to_path(bpy.types.Operator):
|
||||
"""
|
||||
Copy Resources to Directory.
|
||||
@ -33,6 +45,10 @@ class BSBST_OT_copy_resources_to_path(bpy.types.Operator):
|
||||
layout.label(text='This will overwrite files in the target directory!', icon='ERROR')
|
||||
layout.label(text=utils.get_resource_directory())
|
||||
|
||||
class BSBST_brush_style(bpy.types.PropertyGroup):
|
||||
name: bpy.props.StringProperty(default='')
|
||||
file_path: bpy.props.StringProperty(default='')
|
||||
|
||||
class BSBST_preferences(bpy.types.AddonPreferences):
|
||||
bl_idname = __package__
|
||||
|
||||
@ -42,6 +58,7 @@ class BSBST_preferences(bpy.types.AddonPreferences):
|
||||
items= [('APPEND', 'Append', 'Append data-blocks and pack image data as local to this file.', 'APPEND_BLEND', 0),\
|
||||
('LINK', 'Link', 'Link data-blocks from resource directory.', 'LINK_BLEND', 1),
|
||||
])
|
||||
brush_styles: bpy.props.CollectionProperty(type=BSBST_brush_style)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@ -90,8 +107,10 @@ class BSBST_preferences(bpy.types.AddonPreferences):
|
||||
|
||||
|
||||
classes = [
|
||||
BSBST_brush_style,
|
||||
BSBST_preferences,
|
||||
BSBST_OT_copy_resources_to_path,
|
||||
BSBST_OT_refresh_brushstroke_styles,
|
||||
]
|
||||
|
||||
def register():
|
||||
|
@ -124,23 +124,13 @@ def set_active_context_brushstrokes_index(self, value):
|
||||
|
||||
def get_brush_style(self):
|
||||
name = self.node_tree.nodes['Brush Style'].node_tree.name
|
||||
return '.'.join(name.split('.')[1:])
|
||||
return name
|
||||
|
||||
def set_brush_style(self, value):
|
||||
ng = bpy.data.node_groups.get(f'BSBST-brushstroke.{value}')
|
||||
ng = bpy.data.node_groups.get(f'{value}')
|
||||
self.node_tree.nodes['Brush Style'].node_tree = ng
|
||||
self["brush_style"] = value
|
||||
|
||||
def get_brush_style_items(self, context, edit_text):
|
||||
items = []
|
||||
for ng in bpy.data.node_groups:
|
||||
if not ng.type == 'SHADER':
|
||||
continue
|
||||
if not ng.name.startswith('BSBST-brushstroke.'):
|
||||
continue
|
||||
items += [('.'.join(ng.name.split('.')[1:]), ng.name)]
|
||||
return items
|
||||
|
||||
def link_context_type_items(self, context):
|
||||
items = [
|
||||
('SURFACE_OBJECT', 'Surface Object', 'Link socket preset to context surface object', 'OUTLINER_OB_SURFACE', 1),\
|
||||
@ -250,7 +240,7 @@ def register():
|
||||
bpy.utils.register_class(c)
|
||||
bpy.types.Scene.BSBST_settings = bpy.props.PointerProperty(type=BSBST_Settings)
|
||||
bpy.types.Object.modifier_info = bpy.props.CollectionProperty(type=BSBST_modifier_info)
|
||||
bpy.types.Material.brush_style = bpy.props.StringProperty(get=get_brush_style, set=set_brush_style, search=get_brush_style_items, search_options={'SORT'})
|
||||
bpy.types.Material.brush_style = bpy.props.StringProperty(get=get_brush_style, set=set_brush_style, search_options={'SORT'})
|
||||
|
||||
bpy.app.handlers.depsgraph_update_post.append(utils.find_context_brushstrokes)
|
||||
|
||||
|
@ -125,6 +125,8 @@ def draw_panel_ui_recursive(panel, panel_name, mod, items, display_mode, hide_pa
|
||||
col.prop(s, 'hide_ui', icon_only=True, icon='UNPINNED' if s.hide_ui else 'PINNED', emboss=False)
|
||||
|
||||
def draw_material_settings(layout, material, surface_object=None):
|
||||
addon_prefs = bpy.context.preferences.addons[__package__].preferences
|
||||
|
||||
layout.prop(material, 'diffuse_color', text='Viewport Color')
|
||||
# draw color options
|
||||
try:
|
||||
@ -202,7 +204,9 @@ def draw_material_settings(layout, material, surface_object=None):
|
||||
brush_header, brush_panel = layout.panel('brush_panel', default_closed = True)
|
||||
brush_header.label(text='Brush Style', icon='BRUSHES_ALL')
|
||||
if brush_panel:
|
||||
brush_panel.prop(material, 'brush_style', text='', icon='BRUSHES_ALL')
|
||||
row = brush_panel.row(align=True)
|
||||
row.prop_search(material, 'brush_style', addon_prefs, 'brush_styles', text='', icon='BRUSHES_ALL')
|
||||
row.operator('brushstroke_tools.refresh_styles', text='', icon='FILE_REFRESH')
|
||||
brush_panel.template_node_inputs(n2)
|
||||
except:
|
||||
pass
|
||||
|
@ -294,6 +294,13 @@ def update_asset_lib_path():
|
||||
lib = asset_libs[asset_lib_name]
|
||||
lib.path = get_resource_directory()
|
||||
|
||||
def refresh_brushstroke_styles(context):
|
||||
addon_prefs = context.preferences.addons[__package__].preferences
|
||||
for ng in bpy.data.node_groups:
|
||||
if 'BSBST-brushstroke' in ng.keys():
|
||||
b_style = addon_prefs.brush_styles.add()
|
||||
b_style.name = ng.name
|
||||
|
||||
def transfer_modifier(modifier_name, target_obj, source_obj):
|
||||
"""
|
||||
Core taken from https://projects.blender.org/studio/blender-studio-pipeline
|
||||
|
Loading…
Reference in New Issue
Block a user