0
$\begingroup$

I run an operator in the console, but the operator properties are not shown in Tool Panel. enter image description here

enter image description here

However, if I run the operator from search, the properties will be shown up. enter image description here enter image description here

How to show operator properties when running operator in scripts or console?

$\endgroup$
1
$\begingroup$

That is called the Redo Panel. Built in operators executed from the command line won't automatically show up here. You would need to make your own operator class with an execute function that has its own properties that are used in executing the operator.

import bpy
from bpy.props import IntProperty, FloatProperty

class BoxOperator(bpy.types.Operator):
    """example of making a box"""
    bl_idname = "object.box_operator"
    bl_label = "Simple Box Operator"
    bl_options = {"REGISTER","UNDO"}

    x_location = FloatProperty()

    def execute(self, context):
        bpy.ops.mesh.primitive_cube_add(enter_editmode=False, location=(self.x_location, 0, 0))
        return {'FINISHED'}


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


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


if __name__ == "__main__":
    register()

    # test call
    bpy.ops.object.box_operator('INVOKE_DEFAULT')

Executing this as a script will work. However, if you register this class and run it from the python console, you will still not get a redo panel. You would need to enter all of this line by line into the python console or execute the operator from the 3d view.

$\endgroup$
  • $\begingroup$ The panel won't show up if I run the operator in the console. $\endgroup$ – 萌香ちゃん Jun 13 '19 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.