0
$\begingroup$

I'm creating addon that adds couple of objects to the scene and I need to control input arguments. Figured out that the best way for me (with almost zero experience with python but 25+ years in other languages, mostly object oriented) is to use existing templates. Two of them that are working perfectly are Addon Add Object and Operator Mesh Add.

I can easily define new properties by adding simple code like this

# my properties

scale: FloatProperty(
    name="Scale",
    description="some description",
    min=0.000001, max=1000,
    default=0.01,
)
clWidth: FloatProperty(
    name="Chain Link Width",
    description="some description",
    min=0.01, max=10000,
    default=12.7,
)
clCount: IntProperty(
    name="Chain Link Pairs",
    description="some description",
    min=20, max=1000,
    default=41,
)

# ... etc

What I'm getting in lower left corner of the screen is input box like this.

enter image description here

What's bugging me a lot are those props outside of red mark atop of dialog. Course, they are important but mostly I don't use them at all. Is there a way to switch their position and put them below my custom properties or somehow collapse them to minimize size of dialog?

I've seen some addons are using different dialogs (the way I like it) but can't figure out how to get different look.

This is an example

enter image description here

Even if there's a way to remove those transform props completely, will be fine because I'm rarely using them and mostly doing all transforms later directly on the scene.

Any suggestions?

$\endgroup$
3
  • 1
    $\begingroup$ I'm sure this has been answered before but can't find it. Please look draw method in the docs docs.blender.org/api/current/…. I think you also have the option to hide individual properties when defining them with the options = {"HIDDEN"} argument docs.blender.org/api/current/… $\endgroup$
    – Gorgious
    Jun 3, 2022 at 12:29
  • $\begingroup$ @Gorgious I've been looking for answer here and around the web but couldn't find anything that I can use to solve it, even a hint. Problem is that those properties are not defined by me so I can't find a way to hide them. Guess they are defined in parent class somewhere else and inherited here. Thanx anyway, I'll take another look in official docs to see if there's something usable. $\endgroup$
    – Wh1T3h4Ck5
    Jun 3, 2022 at 12:45
  • $\begingroup$ If you use the draw method you'll be able to "whitelist" the props you want to display, any prop not specifically part of the draw method will not be displayed $\endgroup$
    – Gorgious
    Jun 3, 2022 at 12:52

1 Answer 1

2
$\begingroup$

You can use options = {"HIDDEN"} to prevent props from being displayed in the default operator layout redo panel.

https://docs.blender.org/api/current/bpy.props.html?highlight=bpy%20props%20floatproperty#bpy.props.FloatProperty

import bpy


class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {"REGISTER", "UNDO"}
    
    hide_me: bpy.props.IntProperty(options={"HIDDEN"})
    show_me: bpy.props.IntProperty()
    show_me_too: bpy.props.IntProperty()


    def execute(self, context):
        print("done")
        return {'FINISHED'}


if __name__ == "__main__":
    bpy.utils.register_class(SimpleOperator)

enter image description here

Alternatively you can "whitelist" props to be displayed and choose how they will be displayed in the draw method. By default the draw method will display all props that do not have the "HIDDEN" option.

https://docs.blender.org/api/current/bpy.types.Operator.html#custom-drawing

import bpy


class SimpleOperator(bpy.types.Operator):
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {"REGISTER", "UNDO"}
    
    hide_me: bpy.props.IntProperty(options={"HIDDEN"})
    hide_me_too: bpy.props.IntProperty()
    show_me: bpy.props.IntProperty()
    show_me_too: bpy.props.IntProperty()


    def execute(self, context):
        print("done")
        return {'FINISHED'}
    
    def draw(self, context):
        row = self.layout.row(align=True)
        row.prop(self, "show_me", text="SHOW ME !!")
        row.prop(self, "show_me_too", text="SHOW ME TOO !!")
        self.layout.prop(self, "show_me", text="or show me like that")


if __name__ == "__main__":
    bpy.utils.register_class(SimpleOperator)

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Yeah, that's exactly what I was looking for. Thanx a million mate. $\endgroup$
    – Wh1T3h4Ck5
    Jun 3, 2022 at 13:09
  • $\begingroup$ Happy to help ! Cheers $\endgroup$
    – Gorgious
    Jun 3, 2022 at 13:40

You must log in to answer this question.

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