2
$\begingroup$

If I start building my scene from scratch using GUI (read: clicking buttons), will I be able to automatically obtain the equivalent Python code that achieves the same end results?

This is a really cool feature that sounds definitely doable, but not sure how to do it.

$\endgroup$

1 Answer 1

4
$\begingroup$

Most actions you perform will have the operator used listed in the info view, just expand the top most editor in the default screen, you can then select and copy any of these steps and paste them into a text file that you can run like a macro.

info editor

While this is an easy way to get started and works fine for simple tasks, it is often recommended to avoid operators in scripts, search here for operator performance to see discussions on the best way to do things. You will also find some steps will have better alternatives than listed in the info window, for example bpy.ops.object.editmode_toggle() is shown in the above list, you will find it better to use bpy.ops.object.mode_set(mode='EDIT') as you clearly change to the mode you need rather than toggling from a random mode when you run the script.

As you learn using python in blender you can start making your own operators, add them to your own addon which can be setup to bind them to shortcuts or custom menus.

$\endgroup$
1
  • $\begingroup$ This is amazing! Thank you so much! I used to struggle so much. $\endgroup$ Commented Oct 28 at 12:30

You must log in to answer this question.

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