brino
(brino)
September 22, 2012, 1:27pm
1
Hi,
I like to run a python script from the command line.
This works fine if I use a extra python file.
blender -b G:\exifblender.blend -s 1 -e 1 -P G:\render.py
But it does not work at all if I want to run a python script wich is saved as text file inside the .blend file.
blender -b G:\exifblender.blend -s 1 -e 1 -P G:\exifblender.blend\Text\render.py
blender -b G:\exifblender.blend -s 1 -e 1 -P G:\exifblender.blend\render.py
both lines above do not work.
Thanks for ideas how to solve this.
Thomas
Try enabling auto running of scripts on load of file in the preferences.
CoDEmanX
(CoDEmanX)
September 24, 2012, 12:53pm
3
question: what do you want to achieve eventually?
you can run a blender-internal text block via pyconsole like:
override = {'edit_text': bpy.data.texts['Text']}
bpy.ops.text.run_script(override)
if you wanna execute a text block when .blend loads, give the text block a name ending with .py (e.g. Text.py). Then tick the checkbox “Register” next to the run script button.
In case you wanna execute code whenever a .blend is loaded, independent of that file, make the code an addon (separate .py file in Blender addon dir) and register a permanent app handler for load_pre or load_post, enable that addon and save as default (so it will be activated by default).
http://www.blender.org/documentation/blender_python_api_2_63_17/bpy.app.handlers.html
dmatter
(dmatter)
January 25, 2013, 12:42pm
4
I was wondering, does anyone know how to import an obj and export it as an fbx using a script? That would then be called from the command line.
CoDEmanX:
question: what do you want to achieve eventually?
you can run a blender-internal text block via pyconsole like:
override = {'edit_text': bpy.data.texts['Text']}
bpy.ops.text.run_script(override)
if you wanna execute a text block when .blend loads, give the text block a name ending with .py (e.g. Text.py). Then tick the checkbox “Register” next to the run script button.
In case you wanna execute code whenever a .blend is loaded, independent of that file, make the code an addon (separate .py file in Blender addon dir) and register a permanent app handler for load_pre or load_post, enable that addon and save as default (so it will be activated by default).
http://www.blender.org/documentation/blender_python_api_2_63_17/bpy.app.handlers.html