Brushstroke Tools: Initial Version #328
@ -487,6 +487,43 @@ class BSBST_OT_preset_toggle_attribute(bpy.types.Operator):
|
||||
modifier_name=self.modifier_name)
|
||||
return {"FINISHED"}
|
||||
|
||||
class BSBST_OT_brushstrokes_toggle_attribute(bpy.types.Operator):
|
||||
"""
|
||||
Toggle use_attribute property for a socket on a specific object's modifier.
|
||||
(Workaround due to how these are actually stored as integer in Blender)
|
||||
"""
|
||||
bl_idname = "brushstroke_tools.brushstrokes_toggle_attribute"
|
||||
bl_label = "Toggle Attribute"
|
||||
bl_description = "Toggle using a named attribute for this input"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
modifier_name: bpy.props.StringProperty(default='GeometryNodes')
|
||||
input_name: bpy.props.StringProperty(default='Socket_2')
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
settings = context.scene.BSBST_settings
|
||||
return settings.preset_object
|
||||
|
||||
def execute(self, context):
|
||||
settings = context.scene.BSBST_settings
|
||||
|
||||
edit_toggle = settings.edit_toggle
|
||||
settings.edit_toggle = False
|
||||
|
||||
active_bs = settings.context_brushstrokes[settings.active_context_brushstrokes_index]
|
||||
bs_ob = bpy.data.objects.get(active_bs.name)
|
||||
if not bs_ob:
|
||||
settings.edit_toggle = edit_toggle
|
||||
return {"CANCELLED"}
|
||||
|
||||
override = context.copy()
|
||||
override['object'] = bs_ob
|
||||
with context.temp_override(**override):
|
||||
bpy.ops.object.geometry_nodes_input_attribute_toggle(input_name=self.input_name,
|
||||
modifier_name=self.modifier_name)
|
||||
return {"FINISHED"}
|
||||
|
||||
classes = [
|
||||
BSBST_OT_new_brushstrokes,
|
||||
BSBST_OT_edit_brushstrokes,
|
||||
@ -496,6 +533,7 @@ classes = [
|
||||
BSBST_OT_preset_add_mod,
|
||||
BSBST_OT_preset_remove_mod,
|
||||
BSBST_OT_preset_toggle_attribute,
|
||||
BSBST_OT_brushstrokes_toggle_attribute,
|
||||
]
|
||||
|
||||
def register():
|
||||
|
@ -95,7 +95,7 @@ def draw_panel_ui_recursive(panel, panel_name, mod, items, display_mode, hide_pa
|
||||
depress=mod[f'{v.identifier}_use_attribute'],
|
||||
icon='SPREADSHEET')
|
||||
else:
|
||||
toggle = input_row.operator('object.geometry_nodes_input_attribute_toggle',
|
||||
toggle = input_row.operator('brushstroke_tools.brushstrokes_toggle_attribute',
|
||||
text='',
|
||||
depress=mod[f'{v.identifier}_use_attribute'],
|
||||
icon='SPREADSHEET')
|
||||
|
Loading…
Reference in New Issue
Block a user