Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
logiciels:blender:accueil [2018/06/13 20:46] resonance [python] |
logiciels:blender:accueil [2019/10/02 12:17] resonance [Ressources] |
||
---|---|---|---|
Ligne 8: | Ligne 8: | ||
En français : | En français : | ||
- | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
Ligne 31: | Ligne 31: | ||
=== la console python === | === la console python === | ||
== ctrl c / ctrl v == | == ctrl c / ctrl v == | ||
- | - copier (ctrl c) au survol de n' | + | - copier (ctrl c) au survol de n' |
- coller (ctrl v) dans la console python ; | - coller (ctrl v) dans la console python ; | ||
- touche entrée pour executer le code | - touche entrée pour executer le code | ||
Ligne 38: | Ligne 38: | ||
bpy.context.object.location.x = 3.654 | bpy.context.object.location.x = 3.654 | ||
</ | </ | ||
+ | pour les paramètres, | ||
+ | == acceder par nom d' | ||
+ | <code python> | ||
+ | steveX = bpy.data.objects[" | ||
+ | </ | ||
+ | === context === | ||
+ | <code python> | ||
+ | Thing Attribute | ||
+ | The current active object | ||
+ | The current selection | ||
+ | The current scene | ||
+ | The currently selected pose bones .selected_pose_bones | ||
+ | </ | ||
+ | <code python> | ||
+ | bpy.context.active_object.name | ||
+ | bpy.context.active_object.modifiers[' | ||
+ | </ | ||
+ | créer une variable pour acceder context sans retaper sans cesse : | ||
+ | <code python> | ||
+ | C = bpy.context | ||
+ | //means that: C.active_object = bpy.context.active_object | ||
+ | >>> | ||
+ | bpy.data.materials[' | ||
+ | </ | ||
+ | <WRAP center round todo 60%> | ||
+ | * Tout est objet | ||
+ | * Les noms se réfère aux objets | ||
+ | * Utiliser le context | ||
+ | * Descendre.dans.les.objets.avec.des.points | ||
+ | </ | ||
+ | === Listes === | ||
+ | <code python> | ||
+ | for ob in bpy.context.selected_objects: | ||
+ | print(ob.name) | ||
+ | </ | ||
+ | <code python> | ||
+ | for ob in bpy.context.selected_objects: | ||
+ | ob.name = ob.name.upper() | ||
+ | </ | ||
+ | select all hidden objects that have ' | ||
+ | <code python> | ||
+ | import bpy | ||
+ | |||
+ | # Selectionner les objects cachés qui ont ' | ||
+ | bpy.ops.object.select_all(action=' | ||
+ | for ob in bpy.context.scene.objects: | ||
+ | if not ob.hide: | ||
+ | continue | ||
+ | |||
+ | if ' | ||
+ | continue | ||
+ | |||
+ | ob.select = True | ||
+ | ob.hide = False | ||
+ | </ | ||
+ | |||
+ | # boucle for | ||
+ | <code python> | ||
+ | import bpy | ||
+ | |||
+ | # Create 600 tiny Monkeys rows of 25, having 1 unit between each Monkey. | ||
+ | for idx in range(600): | ||
+ | x = idx % 25 | ||
+ | y = idx // 25 | ||
+ | bpy.ops.mesh.primitive_monkey_add(radius=0.2, | ||
+ | </ | ||
+ | |||
+ | === modulo et entiers === | ||
+ | <code python> | ||
+ | idx idx % 4 idx // 4 | ||
+ | 0 0 0 | ||
+ | 1 1 0 | ||
+ | 2 2 0 | ||
+ | 3 3 0 | ||
+ | 4 0 1 | ||
+ | 5 1 1 | ||
+ | 6 2 1 | ||
+ | 7 3 1 | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | import bpy | ||
+ | |||
+ | # Create 600 tiny Monkeys in rows of 25, having 1 unit between each Monkey. | ||
+ | for idx in range(600): | ||
+ | x = idx % 25 | ||
+ | y = idx // 25 | ||
+ | bpy.ops.mesh.primitive_monkey_add(radius=0.2, | ||
+ | bpy.ops.object.modifier_add(type=' | ||
+ | bpy.ops.object.shade_smooth() | ||
+ | </ | ||
===== Moteur de jeu ===== | ===== Moteur de jeu ===== | ||
* [[.: | * [[.: |