3
$\begingroup$

I want to access these commands through code and add them in the array

it helps me to make a tool like photoshop actions

enter image description here

bpy.ops.mesh.primitive_cube_add(enter_editmode=False, align='WORLD', location=(0, 0, 0))
bpy.context.space_data.context = 'OBJECT'
bpy.context.object.location[0] = 5
bpy.context.object.location[1] = 10
bpy.context.object.location[2] = 15
bpy.context.object.rotation_euler[0] = 0.523599
bpy.context.object.rotation_euler[1] = 1.22173
bpy.context.object.rotation_euler[2] = 0.349066
$\endgroup$

1 Answer 1

7
$\begingroup$

Copy and Paste.

Previously available via bpy.ops.ui.reports_to_textblock()

How to read all ‘recent reports’ from info window

How do I get the Info window's log text with Python?

The operator appears unavailable in 2.8, however it is a simple matter of selecting and copying from the info area

Silly test script, toggles into the info area, selects all, copies, toggles back to text area and pastes.

import bpy

context = bpy.context

# change to info
context.area.type = 'INFO'
bpy.ops.info.select_all()
bpy.ops.info.report_copy()
context.area.type = 'TEXT_EDITOR'
bpy.ops.text.paste() # silly

The clipboard contents

>>> for line in C.window_manager.clipboard.splitlines():
...     line
...     
"bpy.context.area.ui_type = 'INFO'"
"bpy.context.area.ui_type = 'TEXT_EDITOR'"
'bpy.ops.text.run_script()'
'Python script failed, check the message in the system console'
"bpy.context.area.ui_type = 'TEXT_EDITOR'"
"bpy.context.area.ui_type = 'INFO'"
"bpy.context.area.ui_type = 'TEXT_EDITOR'"
'bpy.ops.text.run_script()'

See the docs for info area space on toggling info report types. a is an 'INFO' type area

>>> a.type
'INFO'

>>> a.spaces.active.show_
                         locked_time
                         region_header
                         report_debug
                         report_error
                         report_info
                         report_operator
                         report_warning
$\endgroup$
2
  • $\begingroup$ oh, it isn't a silly way! it's a clever way! I could access the clipboard by this line of code clipboard = bpy.context.window_manager.clipboard $\endgroup$ Aug 28, 2020 at 14:11
  • 1
    $\begingroup$ silly in that was pasting back into itself.. $\endgroup$
    – batFINGER
    Aug 28, 2020 at 14:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .