Scripting Python dans Blender — API bpy, add-ons, automation, batch processing, création d'outils personnalisés, panels, operators, UI, pipeline et intégration.
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Scripting Python dans Blender — API bpy, add-ons, automation, batch processing, création d'outils personnalisés, panels, operators, UI, pipeline et intégration.
Guide complet du scripting Python dans Blender : API bpy, bmesh,
création d'add-ons, automation, batch processing, panels, operators,
et pipeline d'intégration.
# Appliquer scale/rotation à tous les objetsimport bpy
for obj in bpy.context.scene.objects:
obj.select_set(True)
bpy.ops.object.transform_apply(location=False, rotation=True, scale=True)
# Exporter chaque objet individuellement en OBJimport bpy, os
out = "exports/"
os.makedirs(out, exist_ok=True)
for obj in bpy.data.objects:
bpy.context.view_layer.objects.active = obj
bpy.ops.object.select_all(action='DESELECT')
obj.select_set(True)
bpy.ops.wm.obj_export(filepath=f"{out}/{obj.name}.obj")
# Créer une animation de rotationimport bpy, math
obj = bpy.context.active_object
for frame inrange(0, 100):
bpy.context.scene.frame_set(frame)
obj.rotation_euler.z = frame * math.radians(3.6)
obj.keyframe_insert(data_path="rotation_euler", index=2)
Débogage
# Imprimer toutes les propriétés d'un objetfor prop indir(bpy.context.object):
ifnot prop.startswith('_'):
print(f"{prop}: {getattr(bpy.context.object, prop)}")
# Imprimer l'arborescence bpy.datafor collection in bpy.data.collections:
print(f"Collection: {collection.name}")
for obj in collection.objects:
print(f" {obj.name} ({obj.type})")
# Voir les opérateurs disponiblesprint([op for op indir(bpy.ops) ifnot op.startswith('_')])
# Voir les propriétés d'un operateurprint(bpy.ops.mesh.primitive_cube_add.get_rna().properties)
Pitfalls
bpy n'existe pas en dehors de Blender — tester avec blender --python
bpy.ops échoue en background — certains ops nécessitent un contexte (area)
Scale non uniforme + Modifier — object.scale = (1, 1, 1) avant modificateurs
BMesh non libéré — bm.free() ou fuite mémoire
Context incorrect — passer {'area': ...} ou utiliser override
Blender API changes — Python API change entre versions majeures
Redraw manuel — bpy.context.area.tag_redraw() après changement UI
Add-on non enregistré — bpy.utils.register_class() oublié
Voir Aussi
blender-modeling — Automatisation de modélisation
blender-animation — Scripts d'animation
blender-geometry-nodes — Scripts pour créer/modifier des GN