Modifier Popup

Hello

Is there a way to make following appear in context.window_manager.invoke_popup and have the ability to change context (eg Scene, Render settings, Object, Modifiers etc)

Basically Would like to work fullscreen and occasional summon a popup as such.

Thanks!

that’s pretty simple… create a new operator calling the invoke_props_dialog on invoke(), and copy paste the draw function from the properties_object.py (with some minor changes):

import bpy

class TransformPopup(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.transform_popup"
    bl_label = "Transform Popup"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)

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

        ob = context.active_object

        row = layout.row()

        row.column().prop(ob, "location")
        if ob.rotation_mode == 'QUATERNION':
            row.column().prop(ob, "rotation_quaternion", text="Rotation")
        elif ob.rotation_mode == 'AXIS_ANGLE':
            row.column().prop(ob, "rotation_axis_angle", text="Rotation")
        else:
            row.column().prop(ob, "rotation_euler", text="Rotation")

        row.column().prop(ob, "scale")

        layout.prop(ob, "rotation_mode")
        
        
    def execute(self, context):
        return {'FINISHED'}


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


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


if __name__ == "__main__":
    register()

Now you can assign a shortcut for it in the preferences (or invoke it from the ‘space bar’ menu)

Thank you for taking time to reply.

Similar to code you pasted, I already have popup as such for modifiers:


If I believe correct CodeManX had a snipper somewhere (very grateful to him)!

Regardless, the top part (3D view>…) needs to be in context of PROPERTIES and it should also be functional, replacing the dialog content below based on selection.

Is this possible?

Thanks

What is the code from CodeManX?.. I can’t fully understand the question (the context is more or less accessible from anywhere in an operator… choosing what to display is not that difficult)

This is a Modifier Popup by CodeManX from https://blenderartists.org/forum/archive/index.php/t-293421.html



import bpy


class SimpleOperator(bpy.types.Operator):

    bl_idname = "object.simple_operator"
    bl_label = "Simple Object Operator"
    bl_options = {'REGISTER', 'UNDO'}

    @classmethod
    def poll(cls, context):
        return (context.active_object is not None and
        context.active_object.type == 'MESH') 


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


    def draw(self, context):
        layout = self.layout
        ob = context.object
        md_self = bpy.types.DATA_PT_modifiers
        for md in ob.modifiers:
          box = layout.template_modifier(md)
        if box:
            # match enum type to our functions, avoids a lookup table.
            getattr(md_self, md.type)(md_self, box, ob, md)


    def invoke(self, context, event):
        return context.window_manager.invoke_props_popup(self, event)



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



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



if __name__ == "__main__":
    register()




My intent is to have also Properties (DATA, Object, Scene, World etc) called/displayed in same way in a popup, ideally in same place as shown on screenshot in previous post

All you need to do is to edit the draw function and add whatever properties you want. Since you have access to the ‘context’ in the draw call, you can access to everything in the blend file (for example, context.blenddata will give you total access to bpy.data)…

Probably it might be better to create different operators each for each type of data (object matrix, object modifiers, scene data, world data, etc), and another operator just to let you choose which data you want to see and tweak.

for example, mixing the Transform data and the Modifiers in the same popup:

import bpy



class SimpleOperator(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.simple_operator"
    bl_label = "Edit Modifier"
    bl_options = {'REGISTER', 'UNDO'}
    
    def modifiers_cb(self, context):
        return [(md.name, md.name, '') for md in context.object.modifiers]
    
    modifier = bpy.props.EnumProperty(items=modifiers_cb)
    
    @classmethod
    def poll(cls, context):
        return (context.active_object is not None and
                context.active_object.type == 'MESH')    




    def execute(self, context):
        return {'FINISHED'}
    
    def draw(self, context):
        layout = self.layout
        ob = context.active_object

        #### Transform Data ####
        row = layout.row()
        row.column().prop(ob, "location")
        if ob.rotation_mode == 'QUATERNION':
            row.column().prop(ob, "rotation_quaternion", text="Rotation")
        elif ob.rotation_mode == 'AXIS_ANGLE':
            row.column().prop(ob, "rotation_axis_angle", text="Rotation")
        else:
            row.column().prop(ob, "rotation_euler", text="Rotation")
        row.column().prop(ob, "scale")
        layout.prop(ob, "rotation_mode")
        
        #### Modifier Data ####
        md = ob.modifiers.get(self.modifier)
                
        md_self = bpy.types.DATA_PT_modifiers
        box = layout.template_modifier(md)
        
        if box:
            # match enum type to our functions, avoids a lookup table.
            getattr(md_self, md.type)(md_self, box, ob, md)
        
    def invoke(self, context, event):
        return context.window_manager.invoke_props_dialog(self)


class customMenu ( bpy.types.Menu ):
    bl_label = "Custom Modifier Menu"
    bl_idname = "view3d.modifier_menu"
    
    def draw ( self, context ):
        layout = self.layout
        
        # Adding a modifier menu----------------------------------------------
        layout.operator_menu_enum ( "object.modifier_add", "type", icon="ZOOMIN" )
        layout.separator()
        
        # Adding a smooth/flat shader -----------------------------------------
        layout.operator ( "object.shade_smooth", "Smooth Shading", icon='SOLID' )
        layout.operator ( "object.shade_flat", "Flat Shading", icon='MESH_UVSPHERE' )
        layout.separator()
        
        # Adding existing Modifiers ( if any )
        row = layout.row()
        row.operator_context = 'INVOKE_DEFAULT'
        row.operator_menu_enum("object.simple_operator", "modifier", icon="MODIFIER")




def register():
    bpy.utils.register_module(__name__)


def unregister():
    bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
    register()


Hey guys, I’m using this code to add the modifier list in a popup, but it seems on 2.9 they changed it, and it doesn’t work anymore.

In the blender UI, it’s just layout.template_modifiers()

Do you have an idea on how to use it?

thx :wink:

1 Like