<p><strong>Answers</strong></p>

<blockquote>
  <blockquote>
    <p>I. a learning problem and reference-request.</p>
  </blockquote>
  
  <p>Please, see very good examples <a href="http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Console" rel="nofollow noreferrer">here</a>. The code can also become
  useful
  <a href="https://svn.blender.org/svnroot/bf-blender/branches/apricot/release/scripts/console.py" rel="nofollow noreferrer">here</a>. Good tutorial video <a href="http://blip.tv/pycon-us-videos-2009-2010-2011/pycon-2011-using-blender-s-new-bpy-python-api-4898905" rel="nofollow noreferrer">here</a>. Main docs <a href="http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python" rel="nofollow noreferrer">here</a>.</p>
  
  <blockquote>
    <p>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).</p>
  </blockquote>
  
  <p><code>Press AltGr + &lt;quote key&gt;</code> or select no-dead-key-keyboard, keys such
  as shift-space tend to interrupt with Blender -keys. </p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>The key is auto-completion (not with TAB for some odd reason but
  CTRL+SPACE) and the key command is <code>$ bpy</code>. I haven't yet found a solution for the clipboard, investigating.</p>
  
  <blockquote>
    <p><strong>Example 1: specify a ball to origin with Python in Blender</strong> </p>
    
    <p>Select your ball in 3D mode and then:</p>

<pre><code>$ bpy.context.object.location.xyz=[0,0,0] 
</code></pre>
    
    <p>so you have your ball in origin.</p>
  </blockquote>
</blockquote>

<p><strong>Animation</strong></p>

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

<blockquote>
  <p><strong>Puzze 0: show the details about things</strong></p>

<pre><code>&gt;&gt;&gt; for object in bpy.data.objects: 
         print(object.name + " is at location " + str(object.location))
</code></pre>
  
  <p><strong>Puzzle 1: create cubes (<a href="http://wiki.blender.org/index.php/Doc:2.6/Manual/Extensions/Python/Console" rel="nofollow noreferrer">source</a>)</strong></p>

<pre><code> &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)
</code></pre>
  
  <p><strong>Puzzle 2: perhaps useful things</strong></p>

<pre><code>&gt;&gt;&gt; bpy.context.object.animation_
data
data_clear(
data_create(
visualisation
</code></pre>
</blockquote>

<p><strong>Related Questions</strong></p>

<ol>
<li><p><a href="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/10972637/how-can-i-access-bpy-in-standard-python-console-bpy-is-the-blender-python-thin/10973302#10973302</a></p></li>
<li><p><a href="https://stackoverflow.com/questions/3924294/blender-python-scripting-tutorials?rq=1">https://stackoverflow.com/questions/3924294/blender-python-scripting-tutorials?rq=1</a></p></li>
</ol>

CC BY-SA 3.0
2012-06-09T00:01:22.120Z
2012-06-11T02:19:35.773Z
2017-05-23T11:33:38.633Z
hhh
<p>My friend told me that you could create games in blender and it has an game engine in it. Now I want to do some simple things with blender such as rolling ball, the topic now in this question. </p>

<p><img src="https://i.sstatic.net/ckIWm.png" alt="enter image description here"></p>

<p>Basically, my problem contain </p>

<p><strong>Problems</strong></p>

<blockquote>
  <ol>
  <li><p>a learning problem and reference-request. </p></li>
  <li><p>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). </p></li>
  <li><p>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.</p></li>
  </ol>
</blockquote>

<p><strong>Helper questions</strong></p>

<blockquote>
  <ol>
  <li><p>what kind of modules and functions does it have to edit and tune the Blender -objects?</p></li>
  <li><p>How can I do a rolling ball such as from (-500,0) to (50,0) with 7-turns in 7 seconds?</p></li>
  <li><p>Is it possible to handle basic operations in the Python console?</p></li>
  <li><p>Where can I find Blender-Python code to see examples?</p></li>
  <li><p>How can I render and open up the render-result to a new window with the console?</p></li>
  </ol>
</blockquote>

<video><linux><blender>
How to create a rolling ball with Python in Blender?
hhh
# How to create a rolling ball with Python in Blender?

(Asked by: username_0 on 2012-06-09)

My friend told me that you could create games in blender and it has an game engine in it. Now I want to do some simple things with blender such as rolling ball, the topic now in this question.

![enter image description here](https://i.sstatic.net/ckIWm.png)

Basically, my problem contain

**Problems**

> 1. a learning problem and reference-request.
> 2. 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).
> 3. 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.

**Helper questions**

> 1. what kind of modules and functions does it have to edit and tune the Blender -objects?
> 2. How can I do a rolling ball such as from (-500,0) to (50,0) with 7-turns in 7 seconds?
> 3. Is it possible to handle basic operations in the Python console?
> 4. Where can I find Blender-Python code to see examples?
> 5. How can I render and open up the render-result to a new window with the console?

**Tags:** video, linux, blender


---

## 1 answers

### Answer by username_0 on 2012-06-09. Score: 2

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 +  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
>>> for object in bpy.data.objects: 
         print(object.name + " is at location " + str(object.location))

Puzzle 1: create cubes (source)
 >>> mylayers = [False]*20
 >>> mylayers[0] = True
 >>> add_cube = bpy.ops.mesh.primitive_cube_add
 >>> for index in range(0, 5):
 ...     add_cube(location=(index*3, 0, 0), layers=mylayers)

Puzzle 2: perhaps useful things
>>> 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


---

