https://github.com/timeless-residents/handson-blender-scripts
Collection of Python scripts demonstrating Blender automation for 3D modeling and rendering. Each script showcases different techniques with visual outputs.
https://github.com/timeless-residents/handson-blender-scripts
3d 3d-graphics automation blender blender-python computer-graphics learning-resources python rendering scripting tutorial
Last synced: about 1 month ago
JSON representation
Collection of Python scripts demonstrating Blender automation for 3D modeling and rendering. Each script showcases different techniques with visual outputs.
- Host: GitHub
- URL: https://github.com/timeless-residents/handson-blender-scripts
- Owner: timeless-residents
- Created: 2025-02-04T01:56:52.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-20T22:05:11.000Z (2 months ago)
- Last Synced: 2025-02-20T23:19:44.067Z (2 months ago)
- Topics: 3d, 3d-graphics, automation, blender, blender-python, computer-graphics, learning-resources, python, rendering, scripting, tutorial
- Language: Python
- Homepage: https://timeless-residents.github.io/handson-blender-scripts/
- Size: 14.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Blender Python スクリプト開発環境セットアップガイド
このリポジトリではBlenderのPythonスクリプト開発環境のセットアップ方法を説明します。
## 前提条件
- macOS
- Blenderがインストールされていること
- VS Code(オプション:より良い開発体験のため)## Blenderのコマンドライン実行
### 基本的な起動方法
```bash
/Applications/Blender.app/Contents/MacOS/Blender
```### Pythonスクリプトを実行する場合
```bash
/Applications/Blender.app/Contents/MacOS/Blender --python your_script.py
```### バックグラウンドモード(GUIなし)で実行
```bash
/Applications/Blender.app/Contents/MacOS/Blender --background
```### バックグラウンドでPythonスクリプトを実行(推奨)
```bash
/Applications/Blender.app/Contents/MacOS/Blender --background --python your_script.py
```### エイリアスの設定(オプション)
毎回長いパスを入力する手間を省くために、以下のコマンドでエイリアスを設定できます:
```bash
echo 'alias blender="/Applications/Blender.app/Contents/MacOS/Blender"' >> ~/.zshrc
# または
echo 'alias blender="/Applications/Blender.app/Contents/MacOS/Blender"' >> ~/.bashrc
```## VS Code統合
より効率的な開発のために、VS Codeに開発環境を統合することができます。
### 必要な拡張機能
1. "Blender Development"
2. "Python"### VS Code設定
1. `settings.json` に以下を追加:
```json
{
"blender.executeable": "/Applications/Blender.app/Contents/MacOS/Blender",
"python.analysis.extraPaths": [
"/Applications/Blender.app/Contents/Resources/4.0/scripts/modules"
]
}
```2. `.vscode/launch.json` を作成:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Blender",
"type": "python",
"request": "launch",
"program": "${file}",
"python": "/Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10",
"env": {
"PYTHONPATH": "/Applications/Blender.app/Contents/Resources/4.0/scripts/modules"
}
}
]
}
```3. `.vscode/tasks.json` を作成:
```json
{
"version": "2.0.0",
"tasks": [
{
"label": "Run in Blender",
"type": "shell",
"command": "/Applications/Blender.app/Contents/MacOS/Blender --background --python ${file}",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
```## スクリプト開発のベストプラクティス
スクリプトの最初に以下のようなインポートチェックを入れることを推奨します:
```python
try:
import bpy
except ImportError:
print("このスクリプトはBlenderから実行する必要があります。")
print("以下のコマンドを使用してください:")
print("/Applications/Blender.app/Contents/MacOS/Blender --background --python script.py")
exit(1)
```## 注意事項
- bpyモジュールは直接pipでインストールすることはできません
- スクリプトは必ずBlenderの実行環境から実行する必要があります
- パスやバージョン番号は、インストールされているBlenderのバージョンによって異なる場合があります## キーボードショートカット
- VS Codeでインタープリタを選択: `Command + Shift + P` → "Python: Select Interpreter"
- スクリプトの実行: `Command + Shift + B`(tasks.jsonの設定後)