2
$\begingroup$

I would like to import a fbx file (3Ds Max scene file) and save the project from the command line, how can I do this?

$\endgroup$
3
$\begingroup$

You simply need one operator to import the FBX, and another operator to export the blendfile. Replace the filepath variables with the actual paths you want to use.

# Import FBX
bpy.ops.import_scene.fbx( filepath = yourFBXfilePath )

# Export blend file
bpy.ops.wm.save_mainfile( filepath = yourBlendFilePath )
$\endgroup$
  • $\begingroup$ I'm getting an error: "TypeError: Calling operator "bpy.ops.import_scene.fbx" error, expected a string enum in ('INVOKE_DEFAULT', 'INVOKE_REGION_WIN', 'INVOKE_REGION_CHANNELS', 'INVOKE_REGION_PREVIEW', 'INVOKE_AREA', 'INVOKE_SCREEN', 'EXEC_DEFAULT', 'EXEC_REGION_WIN', 'EXEC_REGION_CHANNELS', 'EXEC_REGION_PREVIEW', 'EXEC_AREA', 'EXEC_SCREEN')" $\endgroup$ – Chunlin Hu Oct 25 '16 at 9:22
  • $\begingroup$ here is my python script $\endgroup$ – Chunlin Hu Oct 25 '16 at 9:23
  • $\begingroup$ import sys import os import bpy blend_dir = os.path.dirname(bpy.data.filepath) if blend_dir not in sys.path: sys.path.append(blend_dir) # Import FBX bpy.ops.import_scene.fbx( "D:\test.fbx" ) # Export blend file bpy.ops.wm.save_mainfile( "D:\test.html" ) $\endgroup$ – Chunlin Hu Oct 25 '16 at 9:23
  • 3
    $\begingroup$ Did you use the filepath keyword argument? This is the kind of error you would get if you'd just run bpy.ops.import_scene.fbx( 'MYPATH' ) instead of bpy.ops.import_scene.fbx( filepath = 'MYPATH' ). $\endgroup$ – TLousky Oct 25 '16 at 9:24
  • $\begingroup$ As I thought :) Make sure to use the filepath argument for both operators. $\endgroup$ – TLousky Oct 25 '16 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.