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 21:00] resonance [python] |
logiciels:blender:accueil [2019/10/02 12:17] (Version actuelle) resonance [Ressources] |
||
---|---|---|---|
Ligne 8: | Ligne 8: | ||
En français : | En français : | ||
- | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
Ligne 57: | Ligne 57: | ||
bpy.context.active_object.modifiers[' | bpy.context.active_object.modifiers[' | ||
</ | </ | ||
- | In the Console: | + | créer une variable pour acceder context sans retaper sans cesse : |
<code python> | <code python> | ||
C = bpy.context | 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 | ||
- | //means that:// C.active_object | + | # Create 600 tiny Monkeys in rows of 25, having 1 unit between each Monkey. |
- | bpy.context.active_object | + | for idx in range(600): |
+ | x = idx % 25 | ||
+ | y = idx // 25 | ||
+ | bpy.ops.mesh.primitive_monkey_add(radius=0.2, location=(x, | ||
+ | bpy.ops.object.modifier_add(type=' | ||
+ | bpy.ops.object.shade_smooth() | ||
</ | </ | ||
===== Moteur de jeu ===== | ===== Moteur de jeu ===== |