0
$\begingroup$

I want to change the scaling mode in blender

enter image description here

based on documentation I can do it:

apply_unit_scale

apply_unit_scale (boolean, (optional)) – Apply Unit, Take into account current Blender units settings (if unset, raw Blender Units values are used as-is)

apply_scale_options

apply_scale_options (enum in ['FBX_SCALE_NONE', 'FBX_SCALE_UNITS', 'FBX_SCALE_CUSTOM', 'FBX_SCALE_ALL'], (optional)) –

I tried to change the scaling mode to unit scaling in blender but I don't know why it didn't work

import bpy

bpy.ops.export_scene.fbx(apply_unit_scale=True)
bpy.ops.export_scene.fbx(apply_scale_options='FBX_SCALE_UNITS')

I have this error in the console:

enter image description here

I also tried to copy and paste the example in the console but I have same error!:

bpy.ops.export_scene.fbx(filepath="", check_existing=True, filter_glob="*.fbx", use_selection=False, use_active_collection=False, global_scale=1.0, apply_unit_scale=True, apply_scale_options='FBX_SCALE_NONE', bake_space_transform=False, object_types={'ARMATURE', 'CAMERA', 'EMPTY', 'LIGHT', 'MESH', 'OTHER'}, use_mesh_modifiers=True, use_mesh_modifiers_render=True, mesh_smooth_type='OFF', use_subsurf=False, use_mesh_edges=False, use_tspace=False, use_custom_props=False, add_leaf_bones=True, primary_bone_axis='Y', secondary_bone_axis='X', use_armature_deform_only=False, armature_nodetype='NULL', bake_anim=True, bake_anim_use_all_bones=True, bake_anim_use_nla_strips=True, bake_anim_use_all_actions=True, bake_anim_force_startend_keying=True, bake_anim_step=1.0, bake_anim_simplify_factor=1.0, path_mode='AUTO', embed_textures=False, batch_mode='OFF', use_batch_own_dir=True, use_metadata=True, axis_forward='-Z', axis_up='Y')
$\endgroup$
5

1 Answer 1

0
$\begingroup$

oh sorry for this stupid question as Robert Gützkow and brockmann mentioned I didn't set the path

import bpy

#example path to store files
path = os.path.expanduser("~/Desktop")

#export fbx
filename = path + 'Test.fbx'
bpy.ops.export_scene.fbx(filepath=filename, use_selection=True,apply_scale_options='FBX_SCALE_UNITS',apply_unit_scale=True)

os.path.join() method in Python join one or more path components intelligently. This method concatenates various path components with exactly one directory separator (‘/’) following each non-empty part except the last path component. If the last path component to be joined is empty then a directory seperator (‘/’) is put at the end.

import bpy

# importing os module  
import os 
  
    
#example path to store files
path = os.path.expanduser("~/Desktop")

# Join various path components  
filename = os.path.join(path, 'Test.fbx')
    
bpy.ops.export_scene.fbx(filepath=filename, use_selection=True,apply_scale_options='FBX_SCALE_UNITS',apply_unit_scale=True)

Instead of setting path manually, I use this solution

$\endgroup$
4
  • 3
    $\begingroup$ Recommend use os.path.join() or have a look into pathlib if you haven't already. $\endgroup$
    – brockmann
    Aug 23, 2020 at 16:47
  • $\begingroup$ @brockmann thank you. I actually don't want to set the path manually is there a way to set the path by the browser for export_scene.fbx? $\endgroup$ Aug 23, 2020 at 17:01
  • $\begingroup$ Pass "INVOKE_DEFAULT" as first argument. See Execution Context in the API docs. This will open the file browser with the settings applied, but you still need to select the location. $\endgroup$
    – Robert Gützkow
    Aug 23, 2020 at 17:02
  • $\begingroup$ Depends how the UI should look like and where do you want to have it. In general such basic questions have an answer here already, just search for it or explain in detail what you'd like to get and why other answers are bad @SeyedMortezaKamali $\endgroup$
    – brockmann
    Aug 23, 2020 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .