ExportHelper

I am exporting multiple types of files to a user chosen directory using ExportHelper. Is there a way of doing this without getting one filename appended to the beginning of the others?

import bpy
import time
count = 3
  
def xml_x_m(ob, f, repeat, count, path):
  ob.rotation_mode = 'QUATERNION'
  move = ob.location.copy()
  rot = ob.rotation_quaternion
  if ob.data.name=="Lamp":
    l=2
  elif ob.data.name=="Camera":
    l=2
  else:
    f.write("Hello World Stamp"+count+"+ ob.data.name+"."+'%03d'%count+" "+path+"\"	file=")
	count=count+1
  ob.rotation_mode = 'XYZ'
  return repeat,count,f
def obj_export(ob, path):
  bpy.ops.object.select_name(name=ob.name, extend=False)
  move = ob.location.copy()
  bpy.ops.transform.translate(value = move*-1)
  bpy.ops.export_scene.obj(filepath=path+ob.data.name+".obj")
  bpy.ops.transform.translate(value = move)
  bpy.ops.object.select_all(action="DESELECT")  
def fbx_export(ob, path):
  ob.rotation_mode = 'QUATERNION'
  bpy.ops.object.select_name(name=ob.name, extend=False)
  move = ob.location.copy()
  bpy.ops.transform.translate(value = move*-1)
  bpy.ops.export_scene.fbx(filepath=path+ob.data.name+".fbx", check_existing=True, global_scale=1.0, 
  axis_forward='Y', axis_up='Z', 
  use_selection=True, object_types = {'MESH'},  path_mode='COPY')
  bpy.ops.transform.translate(value = move)
  ob.rotation_mode = 'XYZ'
  bpy.ops.object.select_all(action="DESELECT")
def write_some_data(context, filepath, use_opt_ExportSelectedOnly, use_opt_exp, p):
  print("running write_some_data...")
  f = open(filepath, "w")
  import os
  path = bpy.path.abspath('//')
  filename = bpy.context.scene.name
  repeat = "null"
  count=1
  f.write("Hello World Stamp 2	"+"<!--"+filepath+" "+str(p.filepath)+"-->	" )
  if use_opt_exp == "XOBJ":
    for ob in bpy.context.scene.objects:
      obj_export(ob, filepath)
      repeat,count,f = xml_x_m(ob, f, repeat, count, path)
  elif use_opt_exp == "XFBX":
    for ob in bpy.context.scene.objects:
      fbx_export(ob, filepath)
      repeat,count,f = xml_x_m(ob, f, repeat, count, path)
  else:
    for ob in bpy.context.scene.objects:
      repeat,count,f = xml_x_m(ob, f, repeat, count, path)
  f.write(
  "Hello World Stamp 1	")
  return {"FINISHED"}
# ExportHelper is a helper class, defines filename and
# invoke() function which calls the file selector.
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty
class ExportSomeData(bpy.types.Operator, ExportHelper):
    """This appiers in the tooltip of the operator and in the generated docs."""
    bl_idname = "export.some_data"  # this is important since its how bpy.ops.export.some_data is constructed
    bl_label = "Exporter Umbra XML"
    # ExportHelper mixin class uses this
    filename_ext = ".xml"
    filter_glob = StringProperty(default="*.xml", options={"HIDDEN"})
    # List of operator properties, the attributes will be assigned
    # to the class instance from the operator settings before calling.
    opt_ExportSelectedOnly = BoolProperty(name="Export Selected Only", description="Exports only selected objects.", default=False)
    opt_exp = EnumProperty(items=(("XOBJ", "OBJ", "Exports wavefront obj"), ("XFBX", "FBX", "Exports autodesk fbx"), ("OPT_C", "More", "Soon")), name="Export Data Type", description="Choose to export from object or mesh data", default="XFBX")
    opt_Type = EnumProperty(items=(("OPT_A", "Object", "Object Data"), ("OPT_B", "Mesh", "Mesh Data")), name="Export Data Type", description="Choose to export from object or mesh data", default="OPT_B")
    @classmethod
    def poll(cls, context):
        return context.active_object != None
    def execute(self, context):
        return write_some_data(context, self.filepath, self.opt_ExportSelectedOnly, self.opt_exp, self)
# Only needed if you want to add into a dynamic menu
def menu_func_export(self, context):
    self.layout.operator(ExportSomeData.bl_idname, text="Text Export Operator")
def register():
    bpy.utils.register_class(ExportSomeData)
    bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
    bpy.utils.unregister_class(ExportSomeData)
    bpy.types.INFO_MT_file_export.remove(menu_func_export)
if __name__ == "__main__":
    register()
    #test call
    bpy.ops.export.some_data('INVOKE_DEFAULT')

you might want to stick some spaces in there to improve readability. maybe paste the code again with the correct formatting :slight_smile:

Sorry about that, thought it was going to be readable. I guess not. Either way, I found a solution using abspath. I just needed to reference the xml and pass it on

testpath=bpy.path.abspath('//', start=filepath)