5,332
edits
Line 21: | Line 21: | ||
==Scripting== | ==Scripting== | ||
[https://docs.blender.org/api/current/index.html Blender Python API] | [https://docs.blender.org/api/current/index.html Blender Python API] | ||
===Getting Started=== | |||
Blender supports scripting as an alternative means of interaction. | |||
Most things are available in the <code>bpy</code> module. | |||
===Saving scripts outside=== | |||
See [https://b3d.interplanety.org/en/using-external-ide-pycharm-for-writing-blender-scripts/ using external ide] and [https://blender.stackexchange.com/questions/51074/how-to-run-a-python-script-external-to-blender-to-run-bpy-commands-in-blendersp]. | |||
By default, everything is stored in the <code>.blend</code> file including your custom scripts. | |||
If you want to store your scripts outside or use another IDE, you will need to have the script inside Blender call the script outside: | |||
<syntaxhighlight lang="python"> | |||
import bpy | |||
filepath = bpy.path.abspath("//myscript.py") | |||
exec(compile(open(filepath).read(), filename, 'exec')) | |||
</syntaxhighlight> | |||
===Resources=== | ===Resources=== |