Scripting in Blender with Python, and working on the API
Moderators: jesterKing, stiv
-
LeHibou
- Posts: 0
- Joined: Sat Mar 10, 2012 1:04 pm
Post
by LeHibou » Thu Sep 06, 2012 1:37 pm
Hi !
I don't have any chance enabling gpu renderin gon my laptop. But I can take advantage of external compute power.
I would like to enable my .blend to have gpu rendering even if I cannot activate it on my laptop.
The following python code won't work :
Code: Select all
import bpy
bpy.context.user_preferences.system.compute_device_type = 'CUDA'
How could I do this ?
I really need this, really.
Thanks !
LeHibou[/code]
-
dustractor
- Posts: 0
- Joined: Mon Dec 10, 2007 1:52 am
- Location: arkansas
Post
by dustractor » Thu Sep 20, 2012 10:43 pm
I think the problem is the order that scripts run at launch. Cycles is an addon -> addons are loaded after startup folder scripts.
Perhaps some way to delay until blender is finished launching, make sure cycles is loaded/activated, then try your line of code line?
I have my prefs set up in a startup script, all works except the enabling cuda part.
heres that prefs.py:
Code: Select all
import bpy
#\\\
AUTHOR = 'dust'
#///
def set_prefs(context):
prefs = context.user_preferences
filepaths = prefs.filepaths
filepaths.font_directory = "/Library/Fonts/"
filepaths.animation_player= "/Applications/djv-0.9.0.app/Contents/MacOS/djv-0.9.0"
filepaths.animation_player_preset = "DJV"
filepaths.image_editor = '/Applications/GIMP.app'
filepaths.texture_directory = '/Users/dust/Pictures/texture/'
filepaths.render_output_directory = '/Users/dust/Desktop/'
filepaths.show_thumbnails = True
inputs = prefs.inputs
inputs.use_mouse_continuous = True
view = prefs.view
view.show_splash = False
view.use_auto_perspective = True
system = prefs.system
system.compute_device_type = 'CUDA'
#\\\
system.author = AUTHOR
#///
edit = prefs.edit
edit.use_enter_edit_mode = True
edit.object_align = 'VIEW'
bpy.ops.script.execute_preset(
filepath="/Applications/blender.app/Contents/MacOS/2.63/scripts/presets/interface_theme/Elsyiun.xml",
menu_idname="USERPREF_MT_interface_theme_presets")
def register():
if not bpy.context.user_preferences.system.author:
#\\\
print('setting preferences for author:',AUTHOR)
#///
set_prefs(bpy.context)
if __name__ == "__main__":
register()