Skip to main content
added 161 characters in body
Source Link
Martynas Žiemys
  • 27.9k
  • 2
  • 38
  • 81

Operators usually have their properties available in Adjust Last operator panel (F9) so if an operator has some property and has 'REGISTER' and 'UNDO' options:

enter image description here

it will show up in the panel after being used:

enter image description here

That's sort of standard way of doing things in Blender, but if you needed to have some property set before the operator is executed, you need to store it somewhere. If I understand it correctly, one common way to store global properties is in WindowManager:

import bpy

bpy.types.WindowManager.int_p = bpy.props.IntProperty(name = "Some Name", default=15)

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"
    
    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.prop(context.window_manager, "int_p")
        row.operator("mesh.primitive_cylinder_add").vertices = context.window_manager.int_p

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


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


if __name__ == "__main__":
    register()

And here is the link with all the parameters available for integer properties

Operators usually have their properties available in Adjust Last operator panel (F9) so if an operator has some property and has 'REGISTER' and 'UNDO' options:

enter image description here

it will show up in the panel after being used:

enter image description here

That's sort of standard way of doing things in Blender, but if you needed to have some property set before the operator is executed, you need to store it somewhere. If I understand it correctly, one common way to store global properties is in WindowManager:

import bpy

bpy.types.WindowManager.int_p = bpy.props.IntProperty(name = "Some Name", default=15)

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"
    
    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.prop(context.window_manager, "int_p")
        row.operator("mesh.primitive_cylinder_add").vertices = context.window_manager.int_p

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


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


if __name__ == "__main__":
    register()

Operators usually have their properties available in Adjust Last operator panel (F9) so if an operator has some property and has 'REGISTER' and 'UNDO' options:

enter image description here

it will show up in the panel after being used:

enter image description here

That's sort of standard way of doing things in Blender, but if you needed to have some property set before the operator is executed, you need to store it somewhere. If I understand it correctly, one common way to store global properties is in WindowManager:

import bpy

bpy.types.WindowManager.int_p = bpy.props.IntProperty(name = "Some Name", default=15)

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"
    
    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.prop(context.window_manager, "int_p")
        row.operator("mesh.primitive_cylinder_add").vertices = context.window_manager.int_p

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


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


if __name__ == "__main__":
    register()

And here is the link with all the parameters available for integer properties

Source Link
Martynas Žiemys
  • 27.9k
  • 2
  • 38
  • 81

Operators usually have their properties available in Adjust Last operator panel (F9) so if an operator has some property and has 'REGISTER' and 'UNDO' options:

enter image description here

it will show up in the panel after being used:

enter image description here

That's sort of standard way of doing things in Blender, but if you needed to have some property set before the operator is executed, you need to store it somewhere. If I understand it correctly, one common way to store global properties is in WindowManager:

import bpy

bpy.types.WindowManager.int_p = bpy.props.IntProperty(name = "Some Name", default=15)

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Layout Demo"
    bl_idname = "SCENE_PT_layout"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "scene"
    
    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.prop(context.window_manager, "int_p")
        row.operator("mesh.primitive_cylinder_add").vertices = context.window_manager.int_p

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


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


if __name__ == "__main__":
    register()