diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 14:54:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-01-14 14:54:57 +0400 |
commit | e57d3fab9d8d127827affff8223d773b7bb0d7c8 (patch) | |
tree | ec6fdb74053451b7a367731bea77a7f83d4e426b /render_povray | |
parent | f02b630d528dbfeab7f8f787086340522cc57a20 (diff) |
add userprefs for povray binary location.
Diffstat (limited to 'render_povray')
-rw-r--r-- | render_povray/__init__.py | 31 | ||||
-rw-r--r-- | render_povray/render.py | 53 |
2 files changed, 60 insertions, 24 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py index f9503e49..d9438b39 100644 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -40,6 +40,9 @@ if "bpy" in locals(): else: import bpy + from bpy.types import (AddonPreferences, + PropertyGroup, + ) from bpy.props import (StringProperty, BoolProperty, IntProperty, @@ -57,7 +60,7 @@ else: ############################################################################### # Scene POV properties. ############################################################################### -class RenderPovSettingsScene(bpy.types.PropertyGroup): +class RenderPovSettingsScene(PropertyGroup): # File Options tempfiles_enable = BoolProperty( name="Enable Tempfiles", @@ -290,7 +293,7 @@ class RenderPovSettingsScene(bpy.types.PropertyGroup): ############################################################################### # Material POV properties. ############################################################################### -class RenderPovSettingsMaterial(bpy.types.PropertyGroup): +class RenderPovSettingsMaterial(PropertyGroup): irid_enable = BoolProperty( name="Enable Iridescence", description="Newton's thin film interference (like an oil slick on a puddle of " @@ -393,7 +396,7 @@ class RenderPovSettingsMaterial(bpy.types.PropertyGroup): ############################################################################### # Texture POV properties. ############################################################################### -class RenderPovSettingsTexture(bpy.types.PropertyGroup): +class RenderPovSettingsTexture(PropertyGroup): #Custom texture gamma tex_gamma_enable = BoolProperty( name="Enable custom texture gamma", @@ -419,7 +422,7 @@ class RenderPovSettingsTexture(bpy.types.PropertyGroup): ############################################################################### # Object POV properties. ############################################################################### -class RenderPovSettingsObject(bpy.types.PropertyGroup): +class RenderPovSettingsObject(PropertyGroup): # Importance sampling importance_value = FloatProperty( name="Radiosity Importance", @@ -456,7 +459,7 @@ class RenderPovSettingsObject(bpy.types.PropertyGroup): ############################################################################### # Camera POV properties. ############################################################################### -class RenderPovSettingsCamera(bpy.types.PropertyGroup): +class RenderPovSettingsCamera(PropertyGroup): #DOF Toggle dof_enable = BoolProperty( name="Depth Of Field", description="EnablePOV-Ray Depth Of Field ", @@ -504,13 +507,29 @@ class RenderPovSettingsCamera(bpy.types.PropertyGroup): ############################################################################### # Text POV properties. ############################################################################### -class RenderPovSettingsText(bpy.types.PropertyGroup): +class RenderPovSettingsText(PropertyGroup): custom_code = BoolProperty( name="Custom Code", description="Add this text at the top of the exported POV-Ray file", default=False) +############################################################################### +# Povray Preferences. +############################################################################### +class PovrayPreferences(AddonPreferences): + bl_idname = __name__ + + filepath_povray = StringProperty( + name="Povray Location", + description="Path to renderer executable", + subtype='FILE_PATH', + ) + def draw(self, context): + layout = self.layout + layout.prop(self, "filepath_povray") + + def register(): bpy.utils.register_module(__name__) diff --git a/render_povray/render.py b/render_povray/render.py index 97b0e73c..ba95ce6e 100644 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -2042,6 +2042,7 @@ class PovrayRender(bpy.types.RenderEngine): write_pov(self._temp_file_in, scene, info_callback) def _render(self, scene): + addon_prefs = bpy.context.user_preferences.addons[__package__].preferences try: os.remove(self._temp_file_out) # so as not to load the old file @@ -2052,7 +2053,16 @@ class PovrayRender(bpy.types.RenderEngine): print ("***-STARTING-***") - pov_binary = "povray" + # Use the system preference if its set. + pov_binary = addon_prefs.filepath_povray + pov_binary_default = "povray" + if pov_binary: + pov_binary_found = os.path.exists(pov_binary) + else: + pov_binary = pov_binary_default + pov_binary_found = False + + extra_args = [] @@ -2079,7 +2089,8 @@ class PovrayRender(bpy.types.RenderEngine): # 64 bits blender if bitness == 64: try: - pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine64" + if not pov_binary_found: + pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine64" self._process = subprocess.Popen( [pov_binary, self._temp_file_ini] + extra_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -2089,7 +2100,8 @@ class PovrayRender(bpy.types.RenderEngine): except OSError: # someone might run povray 32 bits on a 64 bits blender machine try: - pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine" + if not pov_binary_found: + pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine" self._process = subprocess.Popen( [pov_binary, self._temp_file_ini] + extra_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -2116,7 +2128,8 @@ class PovrayRender(bpy.types.RenderEngine): #32 bits blender else: try: - pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine" + if not pov_binary_found: + pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine" self._process = subprocess.Popen( [pov_binary, self._temp_file_ini] + extra_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -2124,7 +2137,8 @@ class PovrayRender(bpy.types.RenderEngine): # someone might also run povray 64 bits with a 32 bits build of blender. except OSError: try: - pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine64" + if not pov_binary_found: + pov_binary = winreg.QueryValueEx(regKey, "Home")[0] + "\\bin\\pvengine64" self._process = subprocess.Popen( [pov_binary, self._temp_file_ini] + extra_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @@ -2153,21 +2167,24 @@ class PovrayRender(bpy.types.RenderEngine): # DH - added -d option to prevent render window popup which leads to segfault on linux extra_args.append("-d") - isExists = False - sysPathList = os.getenv("PATH").split(':') - sysPathList.append("") + if not pov_binary_found: + pov_binary_found = False + sysPathList = os.getenv("PATH").split(':') + sysPathList.append("") - for dirName in sysPathList: - if (os.path.exists(os.path.join(dirName, pov_binary))): - isExists = True - break + for dirName in sysPathList: + fn = os.path.join(dirName, pov_binary_default) + if os.path.exists(fn): + pov_binary = fn + pov_binary_found = True + break - if not isExists: - print("POV-Ray 3.7: could not found execute '%s' - not if PATH" % pov_binary) - import traceback - traceback.print_exc() - print ("***-DONE-***") - return False + if not pov_binary_found: + print("POV-Ray 3.7: could not found execute '%s' - not if PATH" % pov_binary) + import traceback + traceback.print_exc() + print ("***-DONE-***") + return False try: self._process = subprocess.Popen([pov_binary, self._temp_file_ini] + extra_args, |