3
$\begingroup$

I am running a node tool with python, but when it's executed, the Adjust Last Operation panel isn't showing up.

class SelectEditOperator(bpy.types.Operator):
    bl_idname = "object.edit_select"
    bl_label = "Edit Brushstroke"
    bl_description = "Select Brushstroke from vertex and edit"
    bl_options = {"REGISTER", "UNDO"}
    

    def execute(self, context):
        bpy.ops.geometry.execute_node_group(asset_library_type='LOCAL', asset_library_identifier="", relative_asset_identifier="NodeTree\\Edit Brushstroke")
        return {'FINISHED'}

There is an undo argument for geometry operators which works with operators like Add Cube, but simply adding , True at the end of the node tool operator doesn't seem to work.

my node tool has inputs,

enter image description here

which show up when i execute the operator from the menu,

enter image description here

but not when i execute it with python.

$\endgroup$
4
  • $\begingroup$ Hello, try adding bl_options = {"REGISTER", "UNDO"} to the class definitions $\endgroup$
    – Gorgious
    Commented May 26 at 19:31
  • $\begingroup$ In addition to Gorgious suggestion, it is also because your operator doesn't have parameters that need to be adjusted after execution. $\endgroup$
    – Harry McKenzie
    Commented May 27 at 4:17
  • $\begingroup$ @Gorgious oh i tested again turns out bl_options = {"REGISTER", "UNDO"} is enough for it to show up. But why would the OP need it to show up if there is nothing to adjust (since it is called Adjust last Operation) $\endgroup$
    – Harry McKenzie
    Commented May 27 at 4:40
  • 1
    $\begingroup$ Good point, I suspect this is a minimal working example and OP intends to add parameters to the operator. Thanks for the answer. Cheers $\endgroup$
    – Gorgious
    Commented May 27 at 6:46

1 Answer 1

3
$\begingroup$

You won't see any Adjust Last Operation panel because your operator does not have parameters that can be adjusted after execution. In this example I added an adjustable parameter like asset_library_type for example which you can adjust, default being LOCAL. Also as @Gorgious has mentioned you need to register the bl_options.

import bpy

class SelectEditOperator(bpy.types.Operator):
    bl_idname = "object.edit_select"
    bl_label = "Edit Brushstroke"
    bl_description = "Select Brushstroke from vertex and edit"
    bl_options = {"REGISTER", "UNDO"}

    asset_library_type: bpy.props.EnumProperty(
        name="Asset Library Type",
        items=[
            ('LOCAL', "LOCAL", "Local Blender file"),
            ('ALL', "ALL", "All"),
            ('ESSENTIALS', "USER", "User"),
            ('CUSTOM', "CUSTOM", "Custom"),
        ],
        default='LOCAL'
    )
    
    def execute(self, context):
        bpy.ops.geometry.execute_node_group(
            asset_library_type=self.asset_library_type,
            asset_library_identifier="",
            relative_asset_identifier="NodeTree\\Edit Brushstroke"
        )
        self.report({'INFO'}, f"SelectEditOperator Executed")
        return {'FINISHED'}

    def draw(self, context):
        layout = self.layout
        layout.prop(self, "asset_library_type")

def register():
    bpy.utils.register_class(SelectEditOperator)

def unregister():
    bpy.utils.unregister_class(SelectEditOperator)

if __name__ == "__main__":
    register()

The parameter asset_library_type is just an example, changing the option from LOCAL to another doesn't work yet you have to fix that if ever you want to use this parameter. Or use another attribute as parameter. The point is you need to specify an adjustable parameter in order to see the Adjust Last Operation popup panel.

$\endgroup$
3
  • $\begingroup$ this works, but it exposes the asset library type parameter, which i don't need. the node tool does have adjustable parameters (socket inputs i made in the node editor with names i chose, and with automatically given data path names like "Socket_3") which show up when i execute it from the menu. how do i expose those parameters? $\endgroup$
    – Walter
    Commented May 27 at 8:30
  • 1
    $\begingroup$ @Walter You can expose them using blender.stackexchange.com/q/317571/142292 $\endgroup$
    – Harry McKenzie
    Commented May 27 at 15:40
  • 1
    $\begingroup$ ah thanks, that fixed it! $\endgroup$
    – Walter
    Commented May 27 at 18:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .