LuxBlend25: Saving presets issue + .diff with fix

Discussion related to the 'LuxBlend' Blender 2.4+ python exporter script.

Moderators: Ratow, SATtva, coordinators

LuxBlend25: Saving presets issue + .diff with fix

Postby mdias » Sat Dec 11, 2010 11:25 pm

Hi

When saving presets, the try_preset_path_create() function only tries the first item returned by bpy.utils.preset_paths().
I changed this and here is the resulting .diff:
Code: Select all
diff -r a30b6b757171 src/luxrender/operators/__init__.py
--- a/src/luxrender/operators/__init__.py   Sat Dec 11 23:30:48 2010 +0000
+++ b/src/luxrender/operators/__init__.py   Sun Dec 12 04:17:56 2010 +0000
@@ -47,9 +47,16 @@
# Per-IDPropertyGroup preset handling

def try_preset_path_create(preset_subdir):
-   target_path = os.path.join(bpy.utils.preset_paths('')[0], preset_subdir)
-   if not os.path.exists(target_path):
-      os.makedirs(target_path)
+   # iterate through all the possible preset paths
+   for p in bpy.utils.preset_paths(''):
+      # build path with subdir
+      target_path = os.path.join(p, preset_subdir)
+      if not os.path.exists(target_path):
+         if os.access(p, os.W_OK):
+            os.makedirs(target_path)
+            return
+      else:
+         return

class LUXRENDER_MT_base(object):
   preset_operator = "script.execute_preset"
@@ -372,4 +379,4 @@
      return {'FINISHED'}

menu_func = lambda self, context: self.layout.operator("export.luxrender", text="Export LuxRender Scene...")
-bpy.types.INFO_MT_file_export.append(menu_func)
\ No newline at end of file
+bpy.types.INFO_MT_file_export.append(menu_func)


I tested this and it's working nicely. Now the only thing needed is to convince the blender devs to automatically create the directory structure (scripts, presets, etc) in the user's home folder at blender's startup, if not yet created.

Feedback is welcome.
mdias
 
Posts: 33
Joined: Sat Jun 06, 2009 6:14 pm

Re: LuxBlend25: Saving presets issue + .diff with fix

Postby dougal2 » Sun Dec 12, 2010 7:04 am

Thanks again, that looks useful.

The other issue that I also want to work out with the blender guys is how to distribute some factory presets, at the minute they are kept in a location away from the addon, which makes installation difficult for users.
User avatar
dougal2
Developer
 
Posts: 3075
Joined: Mon Jan 14, 2008 7:21 am

Re: LuxBlend25: Saving presets issue + .diff with fix

Postby mdias » Sun Dec 12, 2010 2:17 pm

No problem.

Do you mean you want to put factory presets inside "/usr/share/blender/2.55/scripts/addons/luxrender/..."? If that's the case, I'd put them on "/usr/share/blender/2.55/scripts/presets/luxrender/..." as that shouldn't pose any problems to package managers, I believe.
The only drawback from this is that the user wouldn't be able to delete those... Maybe we should copy a "presets template" directory to user's home at first run? This way every user would have access to factory defaults and still be able to remove them on a per-user basis.
mdias
 
Posts: 33
Joined: Sat Jun 06, 2009 6:14 pm

Re: LuxBlend25: Saving presets issue + .diff with fix

Postby dougal2 » Mon Dec 13, 2010 4:19 pm

mdias wrote: Maybe we should copy a "presets template" directory to user's home at first run? This way every user would have access to factory defaults and still be able to remove them on a per-user basis.

I think that's a good idea, but I also think that it is something blender should be handling, not LuxBlend25. I will consult the blender devs about this, but I'm a bit short of free time this week.
User avatar
dougal2
Developer
 
Posts: 3075
Joined: Mon Jan 14, 2008 7:21 am

Re: LuxBlend25: Saving presets issue + .diff with fix

Postby mdias » Tue Dec 14, 2010 4:41 am

Makes sense. I'll wait for more info then. :)
mdias
 
Posts: 33
Joined: Sat Jun 06, 2009 6:14 pm


Return to LuxBlend (Blender Exporter)

Who is online

Users browsing this forum: No registered users and 0 guests