Copy from info panel

Hey guys, I need to copy the last entry in the ‘INFO’ region.
I currently have this:

operator_formatting = bpy.context.active_operator.bl_idname.replace(“OT”, “.”)
last_used_operator = “bpy.ops.” + operator_formatting + “()”

Which almost gives me what I need, but it doesn’t give me any parameters of the operator.
I would like to get something like this out of it:

bpy.ops.mesh.primitive_cube_add(radius=24.6)

Anyone got any ideas? I would be very grateful :slight_smile:

If you type something to Python Console and press ctrl+space it will give you suggestions about what is possible.


>>> bpy.context.active_operator.
                                as_keywords(
                                as_pointer(
                                bl_description
                                bl_idname
                                bl_label
                                bl_options
                                bl_rna
                                bl_translation_context
                                bl_undo_group
                                driver_add(
                                driver_remove(
                                get(
                                has_reports
                                id_data
                                is_property_hidden(
                                is_property_readonly(
                                is_property_set(
                                is_repeat(
                                items(
                                keyframe_delete(
                                keyframe_insert(
                                keys(
                                layout
                                macros
                                name
                                options
                                order
                                path_from_id(
                                path_resolve(
                                properties
                                property_unset(
                                report(
                                rna_type
                                type_recast(
                                values(
>>> bpy.context.active_operator.as_keywords()
{'radius': 1.0, 'calc_uvs': False, 'layers': <bpy_boolean[20], MESH_OT_primitive_cube_add.layers>, 'rotation': Euler((0.0, 0.0, 0.0), 'XYZ'), 'location': Vector((0.30579936504364014, -0.957206666469574, 0.941885769367218)), 'enter_editmode': False, 'view_align': False}

I don’t know how to get the operator itself though. What are you trying to atchieve?

Based on batFINGER’s script: https://blender.stackexchange.com/questions/62360/how-do-i-get-the-info-windows-log-text-with-python


import bpy
#remove other Recent Reports
reports = [bpy.data.texts.remove(t, do_unlink=True) 
           for t in bpy.data.texts
           if t.name.startswith("Recent Reports")]
# make a report
bpy.ops.ui.reports_to_textblock()
# print the report
line = bpy.data.texts['Recent Reports'].lines[-2].body
last_command = line[line.find(" ")+1:]
print ("Last command:", last_command)

Thank you so much juhaW, works! :smiley:
and MartinZ I wen’t through everything in that list haha