6

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?

David
  • 49,291
  • 38
  • 159
  • 317
Stan Paillereau
  • 569
  • 4
  • 13

1 Answers1

10

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")
CodeManX
  • 29,298
  • 3
  • 89
  • 128
  • 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 ? – Stan Paillereau Oct 27 '14 at 14:22
  • 1
    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 – CodeManX Oct 30 '14 at 12:01