How to create a rolling ball with Python in Blender?
Answers


  
    I. a learning problem and reference-request.
  
  
  Please, see very good examples here. The code can also become
  useful
  here. Good tutorial video here. Main docs here.
  
  
    II. I am using DVO -layout where many keys such as " and ' are broken -- and many hotkeys are broken (things are apparently
    hard-coded to QWE -layout).
  
  
  Press AltGr + &lt;quote key&gt; or select no-dead-key-keyboard, keys such
  as shift-space tend to interrupt with Blender -keys. 
  
  
    III. I find it hard to find help about using python inside Blender, besides broken window-paste-board in X, lack of TAB as auto-completion
    and lack of good examples.
  
  
  The key is auto-completion (not with TAB for some odd reason but
  CTRL+SPACE) and the key command is $ bpy. I haven't yet found a solution for the clipboard, investigating.
  
  
    Example 1: specify a ball to origin with Python in Blender 
    
    Select your ball in 3D mode and then:

$ bpy.context.object.location.xyz=[0,0,0] 

    
    so you have your ball in origin.
  


Animation

It is not easy to explain this so some puzzles while also working on it.


  Puzze 0: show the details about things

&gt;&gt;&gt; for object in bpy.data.objects: 
         print(object.name + " is at location " + str(object.location))

  
  Puzzle 1: create cubes (source)

 &gt;&gt;&gt; mylayers = [False]*20
 &gt;&gt;&gt; mylayers[0] = True
 &gt;&gt;&gt; add_cube = bpy.ops.mesh.primitive_cube_add
 &gt;&gt;&gt; for index in range(0, 5):
 ...     add_cube(location=(index*3, 0, 0), layers=mylayers)

  
  Puzzle 2: perhaps useful things

&gt;&gt;&gt; bpy.context.object.animation_
data
data_clear(
data_create(
visualisation



Related Questions


https://stackoverflow.com/questions/10972637/how-can-i-access-bpy-in-standard-python-console-bpy-is-the-blender-python-thin/10973302#10973302
https://stackoverflow.com/questions/3924294/blender-python-scripting-tutorials?rq=1