Blender (software): Difference between revisions

From David's Wiki
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===

Revision as of 17:03, 1 June 2021

Blender is an open-source 3D modelling software.
It can be used for creating 3D models for games, 2D/3D animations, and even video games.

Getting Started

Installation

Windows

Direct Download
From chocolatey:

choco install blender
Ubuntu

Blender is available on the Snap store

sudo snap install blender --classic

Modelling

Scripting

Blender Python API

Getting Started

Blender supports scripting as an alternative means of interaction. Most things are available in the bpy module.

Saving scripts outside

See using external ide and [1].

By default, everything is stored in the .blend 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:

import bpy
filepath = bpy.path.abspath("//myscript.py")
exec(compile(open(filepath).read(), filename, 'exec'))

Resources

Resources