Find Selected and Duplicate in an Operator Function

So, I’m learning python for blender (kinda) and I want to make a sort of ‘duplicate’ button as a ui panel. this is what I have, and I want to duplicate selected on line 14.

import bpy

class ultimatePanel(bpy.types.Panel):
    bl_label = "Ultimate Panel"
    bl_idname = "Ultimate_PT_Panel"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Ultimate Panel'
    
    def draw(self, context):
        layout = self.layout
        # col = layout.column()
        row = layout.row()
        row.operator(, icon="DUPLICATE")
        

def register():
    bpy.utils.register_class(ultimatePanel)
def unregister():
    bpy.utils.unregister_class(ultimatePanel)
    
if __name__ == "__main__":
    register()

turn on python tooltips in the settings menu and when you hover over an existing operator it will tell you what the python operator is:

1 Like

i found this, but when i put it like this, it doesn’t work.


error:

hrm… well first- selected_objects.duplicate isn’t an operator, the one i linked is object.duplicate_move(), but, uilayout’s operator function expects a string, so you’d actually use it this way:
row.operator('object.duplicate_move')

1 Like

thank you so much! this is exactly what I was looking for.