6
$\begingroup$

I tried to use options={'HIDDEN'} when I declare my property but it doesn't seems to work. Is there a way to hide a custom property in the UI panel?

$\endgroup$

1 Answer 1

9
$\begingroup$

options={'HIDDEN'} prevents operator properties from being auto-drawn. If you define a custom draw() method, nothing will be hidden.

import bpy

class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}

    prop = bpy.props.BoolProperty(options={'HIDDEN'})

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


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

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

if __name__ == "__main__":
    register()

To hide global properties, simply don't draw them. You may use conditions to draw properties in certain circumstances:

class HelloWorldPanel(bpy.types.Panel):
    """Creates a Panel in the Object properties window"""
    bl_label = "Hello World Panel"
    bl_idname = "OBJECT_PT_hello"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"

    def draw(self, context):
        layout = self.layout

        if context.object is not None:
            layout.prop(context.object, "name")
$\endgroup$
2
  • $\begingroup$ Thx @CoDEmanX ! that helps me understand the options={'HIDDEN'} statement. I'm not sure I understand the 2nd part of your answer though. Because custom properties are drawn automatically in the "Properties" Category in UI panel (N panel), I'm looking for a way to override that and hide them instead. Is this even possible ? $\endgroup$ Oct 27, 2014 at 14:22
  • 1
    $\begingroup$ The HIDDEN option hides individual operator properties in the Redo panel. If you don't want the user to tweak these properties, remove UNDO from bl_options. If you just want to visually hide all operator properties in the Redo panel, define an empty draw() method: def draw(self, context): pass $\endgroup$
    – CodeManX
    Oct 30, 2014 at 12:01

You must log in to answer this question.

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