lp://staging/~diresu/blender/blender-command-port-002
This is a branch of Blender (http://
Blender can be started in server mode and Clients can connect and send Python commands via the command port to the server.
For more detailed information concerning older versions (2.4) see http://
NOTES:
- This branch contains the Blender Command Port branch from version 2.5 up.
- For older (and working) versions (Blender 2.4*) see https:/
EXAMPLE:
# starting the server:
blender -p 10 10 800 600 --command-port 6789
> found bundled python: /home/dietrich/
> Starting the Blender command port - listening on port 6789.
# starting the python client shell
blash --port 6789
> This is Blash - the GNU BLender-Again SHell :)
> Connection to Blender Server established. (IP address: 127.0.0.1, port: 6789)
import bpy
# adding a monkey
bpy.ops.
bpy.ops.wm.redraw()
# adding another monkey
bpy.ops.
bpy.ops.wm.redraw()
# adding a cube
bpy.ops.
bpy.ops.wm.redraw()
# adding a pyramid
vertices = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 0, 0, 1.27]
faces = [0, 3, 2, 1, 0, 1, 4, 0, 1, 2, 4, 0, 2, 3, 4, 0, 3, 0, 4, 0]
mesh = bpy.data.
mesh.vertices.
mesh.faces.
mesh.vertices.
mesh.faces.
mesh.update()
pyramid = bpy.data.
bpy.context.
bpy.ops.wm.redraw()
# quitting the python client shell
quit
NOTES:
- The operator bpy.ops.wm.redraw() redraws the blender window.
It currently only exist in the blender 2.5 command port branch.
TODO:
- If a better way is found for setting the context in function
run_python() (file: blender/
adapt the command port code also!
- Get this branch:
- bzr branch lp://staging/~diresu/blender/blender-command-port-002
Branch merges
Branch information
Recent revisions
- 15549. By Dietrich Bollmann
-
Added a patch by Marc Weber implementing the installation of 'blash' via cmake.
- 15547. By Dietrich Bollmann
-
Made the 'blash' build code work with the code updated to revision 31636.
- 15545. By Dietrich Bollmann
-
Added an operator to redraw the blender GUI: bpy.ops.
wm.redraw( ). This is meant as a substitute of Blender 2.4*'s Redraw() function...
- 15544. By Dietrich Bollmann
-
Made the command port and the command port client compile and work again.
- 15541. By Dietrich Bollmann
-
* Fixed a bug which caused Python to interpret a multiline input
as complete even whithout a terminating empty input line.The bug was caused by
- the command port clients terminating every command string with a
newline character
- the 'compile_command()' function of the 'codeop' module not
expecting a terminating newline character and interpreting it as
a terminating empty line :)A wrapper function which temporarily overwrites the last newline
character with a null character terminating the string solved the
issue.Test:
Before:
>>> for i in range(3):
... print(i)
0
1
2
...
0
1
2
>>>After:
>>> for i in range(3):
... print(i)
...
0
1
2
>>> - 15540. By Dietrich Bollmann
-
* Finally the blender 2.5 command port works again :)
Fixed the blender context error by using the hack from function
run_python() (file: blender/source/ creator/ creator. c) and borrowing
the bpy.context.scene from the first window in the wm window queue...Example:
# starting the server:
blender -p 10 10 800 600 --command-port 6789
> found bundled python: /home/dietrich/
blendev/ bazaar/ blender/ working/ branches/ blender- command- port/install/ linux2/ .blender/ python
> Starting the Blender command port - listening on port 6789.# starting the client:
blash --port 6789
> This is Blash - the GNU BLender-Again SHell :)
> Connection to Blender Server established. (IP address: 127.0.0.1, port: 6789)import bpy
bpy.ops.mesh.primitive_ monkey_ add(layer = [True]+[False]*31) > {'FINISHED'}
bpy.ops.
mesh.primitive_ monkey_ add(view_ align = False, enter_editmode = False, location = (0, 0, 0), rotation = (0, 0, 0), layer = [True]+[False]*31) > {'FINISHED'}
quit
> bye...
TODO:
- To see the newly created mesh I currently have to cause a redraw
of the GUI by moving the mouse over the blender window...
...Have to find a way to redraw the window from the bash shell.- When executing the following code, the result is printed twice
(and probably the code is executed twice also...).| >>> for i in range(3):
| ... print(i)
| 0
| 1
| 2
| ...
| 0
| 1
| 2
| >>>- If a better way is found for setting the context in function
run_python() (file: blender/source/ creator/ creator. c)
adapt the command port code also!
Branch metadata
- Branch format:
- Branch format 7
- Repository format:
- Bazaar repository format 2a (needs bzr 1.16 or later)