Blender Scripting - Import Collada file and save it as .blend
Question: Right now, I have a script in python that converts a collada (.dae) file into
a blender file (.blend).

In the command Line:

    
    
    C:\Program Files\Blender Foundation\Blender>blender.exe --background --python c:\Users\c.diaz\Desktop\convert_collada_to_blend.py -- c:\Users\c.diaz\Desktop
    \Maya.dae -- c:\Users\c.diaz\Desktop\Result.blend
    

My script:

    
    
    import bpy
    import sys
    
    argv = sys.argv
    argv = argv[argv.index("--") + 1:] # get all args after "--"
    
    dae_in = argv[0]
    blend_out = argv[1]
    
    bpy.ops.wm.collada_import(filepath=dae_in)
    bpy.ops.render.render()
    bpy.ops.wm.save_mainfile(filepath=blend_out)
    

After executing the command, I get a lot of output indicating that It's
actually doing something. However, at the end of the process, I don't know
where the result file is being saved.

Any Help From you guys, I'll appreciate it.


Answer: Look for a file named `--` in the current directory when you enter the
command, in the temp directory, or possibly the same dir as blender.exe.

The location of the [temp
directory](https://docs.python.org/3.4/library/tempfile.html#tempfile.tempdir)
may vary, try

    
    
    import tempfile
    print(tempfile.gettempdir())
    

You use `argv = argv[argv.index("--") + 1:]` to get the args after the first
'--' which includes the extra '--' between the two paths that you are
expecting to be used. The second of these is what you are assigning to
`blend_out`

I expect the command you want to use is

    
    
    C:\Program Files\Blender Foundation\Blender\blender.exe --background
    --python c:\Users\c.diaz\Desktop\convert_collada_to_blend.py
    -- c:\Users\c.diaz\Desktop\Maya.dae c:\Users\c.diaz\Desktop\Result.blend
    

Also of note is your use of `bpy.ops.render.render()`, this doesn't save the
rendered image (assuming you have a camera setup). Use
`bpy.ops.render.render(write_still=True)` to have the rendered image saved to
disk. You may also want to set `bpy.context.scene.render.filepath` to specify
where the image is saved.

