I want to export a list with all my objects in my scene, but it always outputs to the default folder.
I already have a little UI and when I press the button it should open the file browser and I want to set the specific path.
Is there a way to it?
Here is the operator it should work in
#Operator Export
class RGL_OT_export(bpy.types.Operator):
bl_idname = "object.export"
bl_label = "Regalplannung"
bl_description = "Exportier Bestückung"
def execute(self, context):
selection = bpy.context.selected_objects
result = ""
for sel in selection:
bpy.context.object.modifiers["Vollständig gefüllt"].show_viewport = False
parent = sel.parent
parent_0 = parent.dimensions [0]
parent_1 = parent.dimensions [1]
parent_2 = parent.dimensions [2]
x = (sel.name.split("_")[0])
y = (sel.name.split("_")[1])
z = (sel.name.split("_")[2])
h = (sel.name.split("_")[3])
if parent_0 < parent_1:
dims = parent.dimensions [0] / sel.dimensions [0]
else:
dims = parent.dimensions [1] / sel.dimensions [1]
result += "%s - %s - %s - %s - %f\n" % (x, y, z, h, dims)
tempFolder = os.path.abspath (bpy.context.scene.render.filepath)
filename = os.path.join (tempFolder, "newfile.txt")
os.makedirs(os.path.dirname(filename), exist_ok=True)
file = open(filename, "w")
file.write(result)
file.close()
return {'FINISHED'}
ExportHelper
and use aninvoke
method. See blender.stackexchange.com/questions/30678/… blender.stackexchange.com/questions/198831/… blender.stackexchange.com/questions/79373/… $\endgroup$bpy.context
$\endgroup$