The Blender Command Port patch makes it possible to start Blender in Python server mode. Clients can connect and send Python commands via the command port to the server. #6887
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#6887
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
%%%The appended patch makes it possible to start Blender in Python server
mode. Clients can connect and send Python commands via the command
port to the server.
For a screenshot see http://formgames.org/blender/command-port/
Have fun,
Dietrich
The following example shows how the command port can be used to model
a simple pyramid:
Installation
%%%
Changed status to: 'Open'
%%%ideasman this something you are interested in reviewing?%%%
%%%Hi again, Campbell Barton :)
I am very glad that you signed for my command port :)
It took me a while to develop and I initially did it for my own purpose. Only recently, after it became something very helpful for my own work, I decided that I should share my code.
I have to admit that I added plenty of things over the time and that my patch is not implementing one isolated feature as this would be the ideal. Probably the best way to get an impression about how the command port can be used is to build it on top of the blender-2.44.tar.gz tarball by following the instructions I added (or even better those on the page http://formgames.org/blender/command-port/). This way you avoid to mess up your own sources :)
If it doesn't work (I only tested with linux) please let me know!
If you think that something should be done in a different way please let me know also. I will try to adapt things to your ideas.
I hope I do not take too much from your time with my patch.
Thanks again for your help,
Dietrich%%%
%%%From a quick glance, it looks like there is a lot going on in this patch:
It is easier to wade thru patches if they deal with a single topic. Nearly 12,000 lines of code makes for a big patch. Something this large might be better done as an svn branch.%%%
%%%Hi Stephen,
Thanks for your comments!
Sorry ... I initially wrote the command port for myself and didn't intend to publish the code. So some changes and experiments which are not really essential for the command port itself ended up in the code.
This is mostly for the arguments used for the command port.
I found the current code irritating and tried to make things simpler. By the way, wouldn't it be better to use something like GNU getopt for the command-line options anyway?
Mostly for the command port. This makes the development of new clients simpler as it is possible to debug the messages send by them.
:)
Ups ... I didn't mean to re-implement the standard C functions but just chose the name which came first to my mind. No wonder that this has been something used somewhere else :) I should rename those functions to something different!
right!
So how can I make this an svn branch?
Is there some page where the process is described?
After making it a branch I first could refactor those things which should be different and than move my stuff part by part to the trunk - of course only if people agree that the command port is something useful :)
So how should I proceed?
Thanks, Dietrich
%%%
%%%"Sorry ... I initially wrote the command port for myself and didn't
intend to publish the code. So some changes and experiments
which are not really essential for the command port itself ended
up in the code."
If you are still interested in this, it needs to be stripped down to a single feature.%%%
%%%The patch doesn't seem to be as bad as it looks; there were very few conflicts when I applied it and updated to current blender svn. I've attached a diff.
%%%
%%%Index: README
+++ README (working copy)
@@ -24,7 +24,7 @@
- Links--------------------------------------
Getting Involved:
+http://www.blender.org/community/get-involved/
Community:
http://www.blender3d.org/Community/
Index: tools/Blender.py
+++ tools/Blender.py (working copy)
@@ -12,6 +12,8 @@
TODO: clean up and sanitise code - crosscheck with btools and SConstruct
to kill any code duplication
+Contributor(s):
+- Dietrich Bollmann - added command port build code.
"""
import os.path
@@ -163,6 +165,8 @@
@@ -416,6 +420,8 @@
Index: tools/btools.py
+++ tools/btools.py (working copy)
@@ -54,7 +54,8 @@
@@ -86,7 +87,8 @@
def validate_targets(targs, bc):
@@ -296,7 +298,9 @@
Index: source/creator/creator.c
+++ source/creator/creator.c (working copy)
@@ -25,8 +25,14 @@
*
*/
#include <stdlib.h>
@@ -81,11 +87,19 @@
#include "RE_pipeline.h"
+#include "UTL_debug.h"
+#include "UTL_parse_options.h"
+#include "UTL_parse_options_geometry.h"
+
+#ifdef WITH_COMMAND_PORT
+#include "commandport.h" /* the Blender command port (dietrich) /
+#endif
+
/ for passing information between creator and gameengine */
#include "SYS_System.h"
@@ -111,8 +125,15 @@
/* Local Function prototypes /
static void print_help();
+static void print_help_debug(); / (dietrich) */
static void print_version();
+/* handle command port option (dietrich) */
+#ifdef WITH_COMMAND_PORT
+void handle_commandport_option_delete(int *argc, char **argv);
+#endif
+void handle_debug_option_delete(int *argc, char **argv);
+void handle_geometry_option_delete(int *argc, char **argv);
/* defined in ghostwinlay and winlay, we can't include carbon here, conflict with DNA */
#ifdef APPLE
@@ -220,6 +241,9 @@
printf (" -W\t\tForce opening without borders\n");
printf (" -p \tOpen with lower left corner at , \n");
printf (" \tand width and height , \n");
printf (" --geometry {xX}][{+-}{+-}\n"); /* (dietrich) */
printf (" \t--geometry can be used alternatively to the -p option\n");
printf (" \tto specify size and position of the Blender window.\n");
printf ("\nGame Engine specific options:\n");
printf (" -g fixedtime\t\tRun on 50 hertz without dropping frames\n");
printf (" -g vertexarrays\tUse Vertex Arrays for rendering (usually faster)\n");
@@ -228,7 +252,22 @@
printf (" -g linearmipmap\tLinear Texture Mipmapping instead of Nearest (default)\n");
printf ("\nMisc options:\n");
+#ifdef WITH_COMMAND_PORT
+#else
+#endif
printf (" -noaudio\tDisable audio on systems that support audio\n");
printf (" -h\t\tPrint this help text\n");
printf (" -y\t\tDisable script links, use -Y to find out why its -y\n");
@@ -236,25 +275,103 @@
#ifdef WIN32
printf (" -R\t\tRegister .blend extension\n");
#endif
+#ifdef WITH_COMMAND_PORT
+#endif
printf (" -v\t\tPrint Blender version and exit\n");
printf (" --\t\tEnds option processing. Following arguments are \n");
printf (" \t\t passed unchanged. Access via Python's sys.argv\n");
}
+/**
+*/
+static void print_help_debug()
+{
+#ifdef WITH_COMMAND_PORT
+#endif
+}
+
+
double PIL_check_seconds_timer(void);
extern void winlay_get_screensize(int *width_r, int *height_r);
int main(int argc, char **argv)
{
int a, stax, stay, sizx, sizy, i;
SYS_SystemHandle syshandle;
Scene *sce;
int audio;
/* Handle unix and windows style help requests */
if (option_is_defined_delete(&argc, argv, "-h", "--help") ||
}
/* Handle unix and windows style help requests */
if (option_is_defined_delete(&argc, argv, "-hd", "--help=debug")) {
}
/* Handle version request */
if (option_is_defined_delete(&argc, argv, "-v", "--version")) {
}
/* Handle debug mode requests */
handle_debug_option_delete(&argc, argv);
/* Handle geometry option */
handle_geometry_option_delete(&argc, argv);
+#ifdef WITH_COMMAND_PORT
+#endif
#if defined(WIN32) || defined (linux)
#else
#endif
@@ -336,28 +453,23 @@
switch(argv- [x][1]) {
@@ -387,12 +499,6 @@
default:
break;
}
@@ -429,6 +535,12 @@
a++;
sizy= atoi(argv[a]);
@@ -478,6 +590,11 @@
if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio);
}
break;
@@ -493,7 +610,7 @@
BIF_init();
else { /* G.background != 0 */
BPY_start_python(argc, argv);
@@ -713,6 +830,13 @@
printf("\nError: you must specify a path after '- '.\n");
}
break;
+
@@ -784,6 +908,10 @@
set_scene(sce);
}
/* flush stdout and stderr */
fflush(stdout);
fflush(stderr);
screenmain();
return 0;
@@ -812,3 +940,141 @@
BLI_setInterruptCallBack(blender_test_break);
}
+
+/**
+*/
+void handle_debug_option_delete(int *argc, char **argv)
+{
+#ifdef NAN_BUILDINFO
+#endif // NAN_BUILDINFO
+
+}
+/**
+*/
+void handle_geometry_option_delete(int *argc, char **argv)
+{
+}
+#ifdef WITH_COMMAND_PORT
+/**
+*/
+void handle_commandport_option_delete(int *argc, char **argv)
+{
+}
+#endif
+/* fin */
Index: source/creator/SConscript
+++ source/creator/SConscript (working copy)
@@ -15,6 +15,10 @@
+# command port (dietrich)
+if env['WITH_COMMAND_PORT'] == 1:
if env['WITH_BF_BINRELOC']==1:
Index: source/blender/include/mydevice.h
+++ source/blender/include/mydevice.h (working copy)
@@ -35,8 +35,9 @@
*
*/
@@ -207,6 +208,9 @@
#define UNDOPUSH 0x400A
+#ifdef WITH_COMMAND_PORT
+#define COMMAND_PORT_INPUT 0x400B /* (dietrich) */
+#endif
/* REDRAWVIEW3D has to be the first one (lowest number) for buttons! */
#define REDRAWVIEW3D 0x4010
Index: source/blender/include/BIF_mainqueue.h
+++ source/blender/include/BIF_mainqueue.h (working copy)
@@ -27,7 +27,10 @@
*
*/
@@ -37,11 +40,26 @@
#define MAXQUEUE 4096
+unsigned short mainqtest (void);
+unsigned short mainqread (short *val, char *ascii);
+unsigned short mainqread_args (short *val, char *ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+void mainqenter (unsigned short event, short val);
+void mainqenter_ext (unsigned short event, short val, char ascii);
+void mainqenter_args (unsigned short event, short val, char ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+void mainqpushback (unsigned short event, short val, char ascii);
+void mainqpushback_args (unsigned short event, short val, char ascii
+#ifdef WITH_COMMAND_PORT
+#endif
#endif /* BIF_MAINQUEUE_H */
Index: source/blender/src/mainqueue.c
+++ source/blender/src/mainqueue.c (working copy)
@@ -25,7 +25,10 @@
*
@@ -35,16 +38,58 @@
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#include <pthread.h>
+#endif
+#include <stdio.h>
+
#include "BIF_mainqueue.h"
#endif
+#ifdef WITH_MULTI_THREADING_SUPPORT
+/**
+*/
+pthread_mutex_t mainqueue_mutex = PTHREAD_MUTEX_INITIALIZER;
+/**
+*/
+void lock_mainqueue_mutex()
+{
+}
+/**
+*/
+void unlock_mainqueue_mutex()
+{
+}
+#endif
typedef struct {
+#ifdef WITH_COMMAND_PORT
+#endif
} QEvent;
static QEvent mainqueue[MAXQUEUE];
@@ -52,51 +97,154 @@
unsigned short mainqread(short *val, char *ascii)
{
+#ifdef WITH_COMMAND_PORT
+#endif
+}
+
+unsigned short mainqread_args(short *val, char *ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+{
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
nevents--;
+#ifdef WITH_COMMAND_PORT
+#endif
if((*ascii<32)||(*ascii==127)) *ascii=0;
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
}
void mainqenter(unsigned short event, short val)
{
+#ifdef WITH_COMMAND_PORT
+#endif
}
void mainqenter_ext(unsigned short event, short val, char ascii)
{
+#ifdef WITH_COMMAND_PORT
+#endif
+}
+
+void mainqenter_args(unsigned short event, short val, char ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+{
if (!event)
return;
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
+#ifdef WITH_COMMAND_PORT
+#endif
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
}
void mainqpushback(unsigned short event, short val, char ascii)
{
+#ifdef WITH_COMMAND_PORT
+#endif
+}
+
+void mainqpushback_args(unsigned short event, short val, char ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+{
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
+#ifdef WITH_COMMAND_PORT
+#endif
nevents++;
}
+
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
}
unsigned short mainqtest()
{
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
+#ifdef WITH_MULTI_THREADING_SUPPORT
+#endif
}
+/* fin */
Index: source/blender/src/SConscript
+++ source/blender/src/SConscript (working copy)
@@ -33,6 +33,10 @@
incs += ' ' + env['BF_SDL_INC']
incs += ' ' + env['BF_OPENGL_INC']
+# command port (dietrich)
+if env['WITH_COMMAND_PORT'] == 1:
defs = []
if env['BF_TWEAK_MODE'] == 1:
Index: source/blender/src/editscreen.c
+++ source/blender/src/editscreen.c (working copy)
@@ -25,7 +25,8 @@
*
@@ -111,6 +112,10 @@
+#ifdef WITH_COMMAND_PORT
+#include "commandport.h" /* the Blender command port (dietrich) */
+#endif
+
#include "winlay.h"
/* TIPS:
@@ -141,6 +146,12 @@
/* prototypes -------------------*/
int afterqtest(short win, unsigned short evt);
unsigned short screen_qread(short *val, char *ascii);
+unsigned short screen_qread_args(short *val, char *ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+unsigned short filter_event(unsigned short event, short val);
void add_to_mainqueue(Window *win, void *user_data, short evt, short val, char ascii);
static void drawscredge_area(ScrArea *sa);
@@ -947,35 +958,88 @@
return 0;
}
+/**
+*/
+static void wait_for_event()
+{
+}
+/*
static void wait_for_event(void)
{
while (!mainqtest()) {
winlay_process_events(1);
}
}
+*/
+unsigned short screen_qread(short val, char ascii)
{
+#ifdef WITH_COMMAND_PORT
+#endif
+}
+
+unsigned short screen_qread_args(short* val, char* ascii
+#ifdef WITH_COMMAND_PORT
+#endif
+{
unsigned short event;
+#ifdef WITH_COMMAND_PORT
+#endif
return filter_event(event, *val);
+}
+unsigned short filter_event(unsigned short event, short val)
+{
if(event==RIGHTSHIFTKEY || event==LEFTSHIFTKEY) {
else if(event==RIGHTALTKEY || event==LEFTALTKEY) {
else if(event==RIGHTCTRLKEY || event==LEFTCTRLKEY) {
else if(event==COMMANDKEY) { // OSX
@@ -1283,19 +1347,38 @@
int firsttime = 1;
int onload_script = 0;
+#ifdef WITH_COMMAND_PORT
/* Start the command port.
*/
commandport_start();
+#endif
window_make_active(mainwin);
while (1) {
unsigned short event;
short val, towin;
char ascii;
+#ifdef WITH_COMMAND_PORT
+#endif
+#ifdef WITH_COMMAND_PORT
+#endif
@@ -1384,6 +1467,12 @@
BIF_read_file(ext_load_str);
sound_initialize_sounds();
}
+#ifdef WITH_COMMAND_PORT
+#endif
else if ((event==ONLOAD_SCRIPT) && BPY_has_onload_script()) {
/* event queued in setup_app_data() in blender.c, where G.f is checked */
onload_script = 1;
@@ -2133,10 +2222,10 @@
void BIF_wait_for_statechange(void)
{
if (!statechanged) {
Index: source/blender/src/usiblender.c
+++ source/blender/src/usiblender.c (working copy)
@@ -25,7 +25,8 @@
*
*/
@@ -143,6 +144,11 @@
+#ifdef WITH_COMMAND_PORT
+#include "UTL_debug.h" /* debug module (dietrich) /
+#include "commandport.h" / Blender command port (dietrich) */
+#endif
+
#include "SYS_System.h"
#include "PIL_time.h"
@@ -956,7 +962,13 @@
void exit_usiblender(void)
{
struct TmpFont *tf;
+#ifdef WITH_COMMAND_PORT
/* cleanup the command port (dietrich) */
commandport_destroy();
+#endif
tf = G.ttfdata.first;
while(tf)
{
freePackedFile(tf->pf);
@@ -1053,6 +1065,14 @@
MEM_printmemlist();
}
delete_autosave();
/* free debug module
*/
cleanup_debug_mode();
printf("\nBlender quit\n");
Index: source/blender/src/buttons_scene.c
+++ source/blender/src/buttons_scene.c (working copy)
@@ -2428,7 +2428,8 @@
uiDefButI(block, NUM, B_DIFF, "Count:", 170,85,140,20, &G.scene->r.GIphotoncount,
0, 10000000, 10, 10, "Number of photons to shoot");
if(G.scene->r.GIphotonradius==0.0) G.scene->r.GIphotonradius=1.0;
Index: source/blender/src/eventdebug.c
+++ source/blender/src/eventdebug.c (working copy)
@@ -190,6 +190,9 @@
smap(ENDKEY);
smap(REDRAWNLA);
smap(ONLOAD_SCRIPT);
+#ifdef WITH_COMMAND_PORT
+#endif
}
#undef smap
}
Index: source/blender/SConscript
+++ source/blender/SConscript (working copy)
@@ -31,3 +31,8 @@
if env['WITH_BF_QUICKTIME'] == 1:
+# command port (dietrich)
+if env['WITH_COMMAND_PORT'] == 1:
Index: config/win32-vc-config.py
+++ config/win32-vc-config.py (working copy)
@@ -175,3 +175,15 @@
BF_BUILDDIR = '..\build\win32-vc'
BF_INSTALLDIR='..\install\win32-vc'
+
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+# which libraries are necessary for 'readline'? - in the case of linux:
+# todo: READLINE_LIB = 'readline curses'
+
+# fin.
Index: config/linuxcross-config.py
+++ config/linuxcross-config.py (working copy)
@@ -137,3 +137,14 @@
BF_BUILDDIR = '../build/linuxcross'
BF_INSTALLDIR='../install/linuxcross'
+
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+READLINE_LIB = 'readline curses'
+
+# fin.
Index: config/sunos5-config.py
+++ config/sunos5-config.py (working copy)
@@ -169,3 +169,15 @@
PLATFORM_LINKFLAGS = ['']
+
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+# which libraries are necessary for 'readline'? - in the case of linux:
+READLINE_LIB = 'readline curses'
+
+# fin.
Index: config/openbsd3-config.py
+++ config/openbsd3-config.py (working copy)
@@ -158,3 +158,15 @@
BF_BUILDDIR='../build/openbsd3'
BF_INSTALLDIR='../install/openbsd3'
+
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+# which libraries are necessary for 'readline'? - in the case of linux:
+READLINE_LIB = 'readline curses'
+
+# fin.
Index: config/linux2-config.py
+++ config/linux2-config.py (working copy)
@@ -175,3 +175,12 @@
#Link against pthread
PLATFORM_LINKFLAGS = ['-pthread']
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+READLINE_LIB = 'readline curses'
+
Index: config/win32-mingw-config.py
+++ config/win32-mingw-config.py (working copy)
@@ -158,3 +158,15 @@
BF_BUILDDIR = '..\build\win32-mingw'
BF_INSTALLDIR='..\install\win32-mingw'
+
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+# which libraries are necessary for 'readline'? - in the case of linux:
+# todo: READLINE_LIB = 'readline curses'
+
+# fin.
Index: config/darwin-config.py
+++ config/darwin-config.py (working copy)
@@ -183,3 +183,15 @@
BF_BUILDDIR='../build/darwin'
BF_INSTALLDIR='../install/darwin'
+
+# command port (dietrich)
+WITH_COMMAND_PORT = 'false'
+
+# blash - the blender python shell (relies on the command port) (dietrich)
+WITH_BLASH = 'false'
+
+# libraries needed by 'readline' (dietrich)
+# which libraries are necessary for 'readline'? - in the case of linux:
+READLINE_LIB = 'readline curses'
+
+# fin.
Index: SConstruct
+++ SConstruct (working copy)
@@ -24,7 +24,9 @@
Contributor(s): Nathan Letwory.
+# Contributor(s):
+# - Nathan Letwory.
+# - Dietrich Bollmann: added building instructions for the command port and blash (2007/05/01).
@@ -58,9 +60,12 @@
B.possible_types = ['core', 'common', 'blender', 'intern',
+B.binarykind = ['blender' , 'blenderplayer',
##################################
##################################
@@ -230,6 +235,10 @@
if 'blendernogame' in B.targets:
+# blash - the blender python shell (dietrich)
+if env['WITH_COMMAND_PORT'] and 'blash' in B.targets:
B.root_build_dir = env['BF_BUILDDIR']
@@ -310,6 +319,11 @@
+# blash - the blender python shell (dietrich)
+if env['WITH_COMMAND_PORT'] and env['WITH_BLASH']:
Now define some targets
@@ -335,6 +349,7 @@
#-- .blender
dotblendlist = []
dottargetlist = []
+
for dp, dn, df in os.walk('bin/.blender'):
@@ -432,8 +447,15 @@
+if env['WITH_COMMAND_PORT'] and env['WITH_BLASH']: # (dietrich)
Depends(nsiscmd, allinstall)
Default(B.program_list)
if not env['WITHOUT_BF_INSTALL']:
%%%
%%%Hi John Connors,
Thank you (...or should I be angry? :)
Does this mean that something of the code ended up in the blender repository?
After getting no further comment I gave up any hope for it a while ago. So, coming back to this place by chance today, I am quite astonished that somebody had looked at it again :)
As the command port (in a slightly newer version) together with blender works for me as it is, I stopped to develop it further and concentrated on the other side: the blender client I was developing it for.
But of course, if you think to integrate it into blender I am happy to use some time (don't have so much in the moment though) to change it into something you can imagine to make part of the official blender release.
Or - as Stephen Swaney puts it (hello Stephen Swaney :) - to "stripp[...] (it) down to a single feature". I just need to know more exactly what kind of feature you want me to strip it down to :)
Thank you! ...and best wishes, Dietrich%%%
%%%Alas, its not part of Blender. I was just verifying the patch still works ok with more recent versions of Blender than 2.44, in spite of it's size.
It's an interesting thing and might be useful for a project of my own. The patch wouldn't get accepted until its more slimmed down and tested on other platforms, I guess. %%%
%%%Hi John Connors,
...and did it work? Which platform did you use?
I only have Linux so I can't do that myself. And other people seem
not to be interested in the command port.
It would be simple to get rid of my debug option - which actually is
very helpful - and my option parsing code - which probably is better
than what blender uses in the moment (I personally would prefer GNU
getopt() though), but as long as I do not know what the blender team
actually thinks and wants I doubt that it makes sense to change the
code.
I do not believe that the patch would be accepted anyway - [x] and
therefor continue to use and develop my own private blender branch for
the stuff I need [2].
But who knows, may be some day things change :)
Thanks for your interest!
Dietrich
that I am using threads which seem to be deprecated by the blender
team.
I run the server in its own thread and blender with its main loop in
another because I neither like polling nor the complicated and
confusing way, the blender event loop currently is organised. I
therefor had to make the event queue thread save - and I have the
impression that this is not appreciated by the official developers.
blender development to work on their own branch. I could start a
command port branch which would make it easy for others to use the
command port and for me to adapt the code to the current state of the
svn. It also would be easier to discuss changes which would be
necessary to bring the patch into the tunk as well as to implement
these changes.
%%%
%%%Hi,
Here comes a new version of the command port patch.
I adapted the patch to the current state of the blender repository
(Blender 2.46, revision 15538) and, following the advice of Stephen
Swaney "It is easier to wade thru patches if they
deal with a single topic." (Stephen, 2007/08/17), "stripped [it] down to a single feature."
(Stephen, 2007/12/09).
Hope it gets accepted this time :)
Cheers, Dietrich
Example - a simple pyramid
Installation
Note: If you want to try the patch with a newer state of the blender
sources you might update your copy with svn update and rebuild. If you
are lucky the patch still works...
For more information see the blender command port page
at http://formgames.org/blender/command-port/
%%%
%%%A review gave following considerations;
It's basically a good idea, but the patch is gigantic, changing a lot of internals, which is unknown if that's going to be maintained. For an option that not many people will use too problematic. My reason to close this one for now.
The good news is that a similar functionality (commandline python editing) is on the wishlist in Blender itself. After that, an external console should be easy.%%%
Changed status from 'Open' to: 'Archived'
%%%A review gave following considerations;
It's basically a good idea, but the patch is gigantic, changing a lot of internals, which is unknown if that's going to be maintained. For an option that not many people will use too problematic. My reason to close this one for now.
The good news is that a similar functionality (commandline python editing) is on the wishlist in Blender itself. After that, an external console should be easy.%%%
%%%...here:
...hey Ton - this is not to offend you or to protest against / revert your decision!!! We all love you and I am doing
this just for "hyper linking" things. If I can, I will close it immediatly after again ... we will see ...
...and than, some nice guy wrote ( http://lists.blender.org/pipermail/bf-committers/2008-September/021761.html ):
On Fri, 2008-09-19 at 09:56 +0200, Ton Roosendaal wrote:
...snip...
Actually there have been such people. See here for example:
(and you have been one of them a long time ago replying to some messages from Martin DeMello - which I do not find
anymore).
Best wishes, Dietrich :)
By the way - as I am already collecting thing related -
All started with the following message a long time ago:
...which was received very positively by Ton - and probably has been lost in some corner of the internet :(
PS:
By fault I submitted this also as a "new patch" here: https://projects.blender.org/tracker/index.php?func=detail&aid=17664&group_id=9&atid=127 :( ... sorry!%%%
%%%Hi,
I put the command port patch on launchpad for easy upgrade.
Here is the link:
https://code.launchpad.net/~diresu/blender/blender-command-port
If some day later you feel like using it - please feel free to get it from there :)
Thanks for your hard work on developing blender!
With best wishes,
Dietrich
%%%
%%%i'm testing this on win32 now, had to put a lot of stuff from gnuwin32 to satisfy posix dependencies, and commented out stuff that uses readline.
compiles now, failed to open a socket for some reason, i hope that works with the previous revision (which seemed to me be just changes in Bleneder, not in command port) like Dietrich says on the Bazaar page, will try that next. as there's no changes in commandport this same patch should apply.
note: this is not a proper patch to make command port crossplatform, but just a hack to get to test it on win, and does serve to point out the problem points so that a proper crossplat version can be made.
i was surprised to see how much low level string handling and socket stuff there is in this patch (or a plugin..) in c - would it be possible to do the networking in python instead, and just modify the core of blender so that it can call the networking in the mainloop? would ease crossplatformness. or how do you think this sort of stuff should be made in 2.5?%%%
%%%Hi Toni,
Thank you very much for the efforts you put into the command port code!
For porting blash to Windows this looks like a good strategy: Getting
rid of everything not essential, making the code work on windows and
later reintegrate step by step those things which are useful for the
command port functionality.
On the long term though the possibility to edit the command line of
the command port shell client (blash) is a very useful feature to
have and it would be painful to use blash without it.
That said, I have to admit that I use blash never directly but from
emacs together with a variant of the emacs python mode and therefore
personally don't rely on this feature... I also use the command port
from a common lisp client which speaks the "command port protocol"
itself and doesn't rely on blash at all.
There is a readline library for windows: "Readline for Windows"
http://gnuwin32.sourceforge.net/packages/readline.htm . I never
tried it though as I don't own a windows machine.
As you observed, beyond the correction of merge conflicts and
bug-fixes, there have been more or less no changes concerning the
command port code during most of the updates on launchpad.
The only two reasons for this branch to exist are
So there probably is no need to check the previous revision.
To make the socket code work on Windows it is probably easier to first
port the socket modules independent from the rest of the command port
code - or, as you proposed later, to switch to some other socket
library / inter-process communication system.
I worked for a while on a port for blender 2.5. But than I god too
busy (better too poor) to continue. And as the command port works
fine for me and the blender team seemed to not be interested in this
functionality anyway I postponed further development. If you really
plan to write a crossplat version, I can try to find some time to
continue the port to the 2.5 code base.
The new code adds another event queue to the queues already existing
in blender 2.5. The queue is thread safe and therefor can be written
to by the blender server thread which runs independent from the main
blender thread in its own loop.
It would be possible - and a very good idea indeed :)
When I started to work on the patch, I had the impression that the
blender team would prefer a pure C version which doesn't make use of
yet another bunch of libraries. It probably would have been a better
idea to get into touch with the blender developers as fast as
possible at the place of confronting them with the finished patch...
If I would start from scratch again I would use C++ (my C code tries
to use C in an object oriented style), D-Bus (at the place of my own
socket code. D-Bus might still be a good option as it is supported on
Linux, Microsoft Windows and Apple Mac OS X, see for example
http://en.wikipedia.org/wiki/D-Bus ) and some simple XML scheme at the
place of the "command port protocoll" I am using now (see
http://formgames.org/blender/command-port/#bcp-protocol ).
Cheers, Dietrich
%%%
%%%> [...] i hope that works with the previous revision (which seemed to me be just changes in Bleneder, not in command port) like Dietrich says on the Bazaar page [...]
The problems I had with the revision 198 of the command port branch on launchpad probably where caused by a bug in my Debian system and not by the blender code...
See the following thread on bf-committers:
The revision on launchpad probably was not "broken" :)
Regards, Dietrich
By the way, I updated the command port blender branch to 2.49b. See https://code.launchpad.net/~diresu/blender ./blender-command-port%%%
%%%Hi,
I ported the command port to Blender 2.5.
The command port works - but for the moment it is not usable as Blender 2.5's Python API only works when executing Python commands from the Blender GUI. The same commands do not work when executing them from a script via the -P
%%%Since a while already, the command port works again...
See: https://code.launchpad.net/~diresu/blender/blender-command-port-002
Here an example how the new version can be used (from the launchpad page):
EXAMPLE:
starting the server:
blender -p 10 10 800 600 --command-port 6789
starting the python client shell
blash --port 6789
import bpy
adding a monkey
bpy.ops.mesh.primitive_monkey_add(layer = [True]+[False]*19)
bpy.ops.wm.redraw()
adding another monkey
bpy.ops.mesh.primitive_monkey_add(view_align = False, enter_editmode = False, location = (0, 0, 0), rotation = (0, 0, 0), layer = [True]+[False]*19)
bpy.ops.wm.redraw()
adding a cube
bpy.ops.mesh.primitive_cube_add(layer = [True]+[False]*19)
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.meshes.new("Pyramid")
mesh.add_geometry(int(len(vertices) / 3), 0, int(len(faces) / 4))
mesh.verts.foreach_set("co", vertices)
mesh.faces.foreach_set("verts_raw", faces)
mesh.update()
pyramid = bpy.data.objects.new("Pyramid", mesh)
bpy.context.scene.objects.link(pyramid)
bpy.ops.wm.redraw()
quitting the python client shell
quit
NOTE:
%%%
%%%Update: The Blender Python API changed - here is the new testcode (again from the launchpad page https://code.launchpad.net/~diresu/blender/blender-command-port-002 ):
EXAMPLE:
starting the server:
blender -p 10 10 800 600 --command-port 6789
starting the python client shell
blash --port 6789
import bpy
adding a monkey
bpy.ops.mesh.primitive_monkey_add()
bpy.ops.wm.redraw()
adding another monkey
bpy.ops.mesh.primitive_monkey_add(view_align = False, enter_editmode = False, location = (0, 0, 0), rotation = (0, 0, 0))
bpy.ops.wm.redraw()
adding a cube
bpy.ops.mesh.primitive_cube_add()
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.meshes.new("Pyramid")
mesh.vertices.add(len(vertices) // 3)
mesh.faces.add(len(faces) // 4)
mesh.vertices.foreach_set("co", vertices)
mesh.faces.foreach_set("vertices_raw", faces)
mesh.update()
pyramid = bpy.data.objects.new("Pyramid", mesh)
bpy.context.scene.objects.link(pyramid)
bpy.ops.wm.redraw()
quitting the python client shell
quit
NOTES:
%%%