This is the addon I'm trying to modify https://github.com/florianfelix/render_bbake
I'm using it to bake and export textures for meshes that were imported via fbx.
I want to add a path button to it that will allow me to specify a folder for all textures (of all objects/meshes) to be exported to.
I got the folder browse button in there. But I don't know how to format the path before the add-on appends the mesh/ texture filename.
Here's the modified add-on:
These are the relevant changes:
added this property to the BBake_Scene_Data(PropertyGroup) class in batch_bake_object_data.py:
all_path = StringProperty( name='All Path', subtype='DIR_PATH', default='', description='Save all images of all objects in this folder',)
added this to the def draw call in batch_bake_ui.py:
row=box_global.row(align=False) col.separator() row.prop(scene_settings, 'all_path')
modified the testob(ob, context) function (gave it a new parameter so I could pass in the scene settings data object) in batch_bake_operators.py to this:
test = context.scene.bbake.all_path if test: path = test else: path = bpy.path.abspath(ob_settings.path) if not os.path.isdir(path): try: os.makedirs(path) except: msg('FAILED to create bake Folder:%s\n for object "%s"\nSkipping.' %(path, ob.name)) return False
Running this, having specified a folder, "all_path" (just a random empty folder on the desktop), I get a "no such file or directory" error.
Note:99.9% of the code is not mine. It belongs to the former maintainers of this plugin and/or florien/fenix)
Thanks a ton for any help!
Edit: I'm guessing I'm either not getting the string from all_path the right way, or I'm not formatting it properly to work with os.path.isdir.