Cleanup: move 'check_existing' to the bottom of properties
[blender-addons.git] / io_scene_fbx / __init__.py
blob40ca5fc435df53497c48565272627de4f8417a00
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8 compliant>
21 bl_info = {
22 "name": "FBX format",
23 "author": "Campbell Barton, Bastien Montagne, Jens Restemeier",
24 "version": (4, 20, 3),
25 "blender": (2, 81, 6),
26 "location": "File > Import-Export",
27 "description": "FBX IO meshes, UV's, vertex colors, materials, textures, cameras, lamps and actions",
28 "warning": "",
29 "doc_url": "{BLENDER_MANUAL_URL}/addons/import_export/scene_fbx.html",
30 "support": 'OFFICIAL',
31 "category": "Import-Export",
35 if "bpy" in locals():
36 import importlib
37 if "import_fbx" in locals():
38 importlib.reload(import_fbx)
39 if "export_fbx_bin" in locals():
40 importlib.reload(export_fbx_bin)
41 if "export_fbx" in locals():
42 importlib.reload(export_fbx)
45 import bpy
46 from bpy.props import (
47 StringProperty,
48 BoolProperty,
49 FloatProperty,
50 EnumProperty,
51 CollectionProperty,
53 from bpy_extras.io_utils import (
54 ImportHelper,
55 ExportHelper,
56 orientation_helper,
57 path_reference_mode,
58 axis_conversion,
62 @orientation_helper(axis_forward='-Z', axis_up='Y')
63 class ImportFBX(bpy.types.Operator, ImportHelper):
64 """Load a FBX file"""
65 bl_idname = "import_scene.fbx"
66 bl_label = "Import FBX"
67 bl_options = {'UNDO', 'PRESET'}
69 directory: StringProperty()
71 filename_ext = ".fbx"
72 filter_glob: StringProperty(default="*.fbx", options={'HIDDEN'})
74 files: CollectionProperty(
75 name="File Path",
76 type=bpy.types.OperatorFileListElement,
79 ui_tab: EnumProperty(
80 items=(('MAIN', "Main", "Main basic settings"),
81 ('ARMATURE', "Armatures", "Armature-related settings"),
83 name="ui_tab",
84 description="Import options categories",
87 use_manual_orientation: BoolProperty(
88 name="Manual Orientation",
89 description="Specify orientation and scale, instead of using embedded data in FBX file",
90 default=False,
92 global_scale: FloatProperty(
93 name="Scale",
94 min=0.001, max=1000.0,
95 default=1.0,
97 bake_space_transform: BoolProperty(
98 name="!EXPERIMENTAL! Apply Transform",
99 description="Bake space transform into object data, avoids getting unwanted rotations to objects when "
100 "target space is not aligned with Blender's space "
101 "(WARNING! experimental option, use at own risks, known broken with armatures/animations)",
102 default=False,
105 use_custom_normals: BoolProperty(
106 name="Import Normals",
107 description="Import custom normals, if available (otherwise Blender will recompute them)",
108 default=True,
111 use_image_search: BoolProperty(
112 name="Image Search",
113 description="Search subdirs for any associated images (WARNING: may be slow)",
114 default=True,
117 use_alpha_decals: BoolProperty(
118 name="Alpha Decals",
119 description="Treat materials with alpha as decals (no shadow casting)",
120 default=False,
122 decal_offset: FloatProperty(
123 name="Decal Offset",
124 description="Displace geometry of alpha meshes",
125 min=0.0, max=1.0,
126 default=0.0,
129 use_anim: BoolProperty(
130 name="Import Animation",
131 description="Import FBX animation",
132 default=True,
134 anim_offset: FloatProperty(
135 name="Animation Offset",
136 description="Offset to apply to animation during import, in frames",
137 default=1.0,
140 use_subsurf: BoolProperty(
141 name="Import Subdivision Surface",
142 description="Import FBX subdivision information as subdivision surface modifiers",
143 default=False,
146 use_custom_props: BoolProperty(
147 name="Import User Properties",
148 description="Import user properties as custom properties",
149 default=True,
151 use_custom_props_enum_as_string: BoolProperty(
152 name="Import Enums As Strings",
153 description="Store enumeration values as strings",
154 default=True,
157 ignore_leaf_bones: BoolProperty(
158 name="Ignore Leaf Bones",
159 description="Ignore the last bone at the end of each chain (used to mark the length of the previous bone)",
160 default=False,
162 force_connect_children: BoolProperty(
163 name="Force Connect Children",
164 description="Force connection of children bones to their parent, even if their computed head/tail "
165 "positions do not match (can be useful with pure-joints-type armatures)",
166 default=False,
168 automatic_bone_orientation: BoolProperty(
169 name="Automatic Bone Orientation",
170 description="Try to align the major bone axis with the bone children",
171 default=False,
173 primary_bone_axis: EnumProperty(
174 name="Primary Bone Axis",
175 items=(('X', "X Axis", ""),
176 ('Y', "Y Axis", ""),
177 ('Z', "Z Axis", ""),
178 ('-X', "-X Axis", ""),
179 ('-Y', "-Y Axis", ""),
180 ('-Z', "-Z Axis", ""),
182 default='Y',
184 secondary_bone_axis: EnumProperty(
185 name="Secondary Bone Axis",
186 items=(('X', "X Axis", ""),
187 ('Y', "Y Axis", ""),
188 ('Z', "Z Axis", ""),
189 ('-X', "-X Axis", ""),
190 ('-Y', "-Y Axis", ""),
191 ('-Z', "-Z Axis", ""),
193 default='X',
196 use_prepost_rot: BoolProperty(
197 name="Use Pre/Post Rotation",
198 description="Use pre/post rotation from FBX transform (you may have to disable that in some cases)",
199 default=True,
202 def draw(self, context):
203 pass
205 def execute(self, context):
206 keywords = self.as_keywords(ignore=("filter_glob", "directory", "ui_tab", "filepath", "files"))
208 from . import import_fbx
209 import os
211 if self.files:
212 ret = {'CANCELLED'}
213 dirname = os.path.dirname(self.filepath)
214 for file in self.files:
215 path = os.path.join(dirname, file.name)
216 if import_fbx.load(self, context, filepath=path, **keywords) == {'FINISHED'}:
217 ret = {'FINISHED'}
218 return ret
219 else:
220 return import_fbx.load(self, context, filepath=self.filepath, **keywords)
223 class FBX_PT_import_include(bpy.types.Panel):
224 bl_space_type = 'FILE_BROWSER'
225 bl_region_type = 'TOOL_PROPS'
226 bl_label = "Include"
227 bl_parent_id = "FILE_PT_operator"
229 @classmethod
230 def poll(cls, context):
231 sfile = context.space_data
232 operator = sfile.active_operator
234 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
236 def draw(self, context):
237 layout = self.layout
238 layout.use_property_split = True
239 layout.use_property_decorate = False # No animation.
241 sfile = context.space_data
242 operator = sfile.active_operator
244 layout.prop(operator, "use_custom_normals")
245 layout.prop(operator, "use_subsurf")
246 layout.prop(operator, "use_custom_props")
247 sub = layout.row()
248 sub.enabled = operator.use_custom_props
249 sub.prop(operator, "use_custom_props_enum_as_string")
250 layout.prop(operator, "use_image_search")
253 class FBX_PT_import_transform(bpy.types.Panel):
254 bl_space_type = 'FILE_BROWSER'
255 bl_region_type = 'TOOL_PROPS'
256 bl_label = "Transform"
257 bl_parent_id = "FILE_PT_operator"
259 @classmethod
260 def poll(cls, context):
261 sfile = context.space_data
262 operator = sfile.active_operator
264 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
266 def draw(self, context):
267 layout = self.layout
268 layout.use_property_split = True
269 layout.use_property_decorate = False # No animation.
271 sfile = context.space_data
272 operator = sfile.active_operator
274 layout.prop(operator, "global_scale")
275 layout.prop(operator, "decal_offset")
276 layout.prop(operator, "bake_space_transform")
277 layout.prop(operator, "use_prepost_rot")
280 class FBX_PT_import_transform_manual_orientation(bpy.types.Panel):
281 bl_space_type = 'FILE_BROWSER'
282 bl_region_type = 'TOOL_PROPS'
283 bl_label = "Manual Orientation"
284 bl_parent_id = "FBX_PT_import_transform"
286 @classmethod
287 def poll(cls, context):
288 sfile = context.space_data
289 operator = sfile.active_operator
291 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
293 def draw_header(self, context):
294 sfile = context.space_data
295 operator = sfile.active_operator
297 self.layout.prop(operator, "use_manual_orientation", text="")
299 def draw(self, context):
300 layout = self.layout
301 layout.use_property_split = True
302 layout.use_property_decorate = False # No animation.
304 sfile = context.space_data
305 operator = sfile.active_operator
307 layout.enabled = operator.use_manual_orientation
309 layout.prop(operator, "axis_forward")
310 layout.prop(operator, "axis_up")
313 class FBX_PT_import_animation(bpy.types.Panel):
314 bl_space_type = 'FILE_BROWSER'
315 bl_region_type = 'TOOL_PROPS'
316 bl_label = "Animation"
317 bl_parent_id = "FILE_PT_operator"
318 bl_options = {'DEFAULT_CLOSED'}
320 @classmethod
321 def poll(cls, context):
322 sfile = context.space_data
323 operator = sfile.active_operator
325 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
327 def draw_header(self, context):
328 sfile = context.space_data
329 operator = sfile.active_operator
331 self.layout.prop(operator, "use_anim", text="")
333 def draw(self, context):
334 layout = self.layout
335 layout.use_property_split = True
336 layout.use_property_decorate = False # No animation.
338 sfile = context.space_data
339 operator = sfile.active_operator
341 layout.enabled = operator.use_anim
343 layout.prop(operator, "anim_offset")
346 class FBX_PT_import_armature(bpy.types.Panel):
347 bl_space_type = 'FILE_BROWSER'
348 bl_region_type = 'TOOL_PROPS'
349 bl_label = "Armature"
350 bl_parent_id = "FILE_PT_operator"
351 bl_options = {'DEFAULT_CLOSED'}
353 @classmethod
354 def poll(cls, context):
355 sfile = context.space_data
356 operator = sfile.active_operator
358 return operator.bl_idname == "IMPORT_SCENE_OT_fbx"
360 def draw(self, context):
361 layout = self.layout
362 layout.use_property_split = True
363 layout.use_property_decorate = False # No animation.
365 sfile = context.space_data
366 operator = sfile.active_operator
368 layout.prop(operator, "ignore_leaf_bones")
369 layout.prop(operator, "force_connect_children"),
370 layout.prop(operator, "automatic_bone_orientation"),
371 sub = layout.column()
372 sub.enabled = not operator.automatic_bone_orientation
373 sub.prop(operator, "primary_bone_axis")
374 sub.prop(operator, "secondary_bone_axis")
377 @orientation_helper(axis_forward='-Z', axis_up='Y')
378 class ExportFBX(bpy.types.Operator, ExportHelper):
379 """Write a FBX file"""
380 bl_idname = "export_scene.fbx"
381 bl_label = "Export FBX"
382 bl_options = {'UNDO', 'PRESET'}
384 filename_ext = ".fbx"
385 filter_glob: StringProperty(default="*.fbx", options={'HIDDEN'})
387 # List of operator properties, the attributes will be assigned
388 # to the class instance from the operator settings before calling.
390 use_selection: BoolProperty(
391 name="Selected Objects",
392 description="Export selected and visible objects only",
393 default=False,
395 use_active_collection: BoolProperty(
396 name="Active Collection",
397 description="Export only objects from the active collection (and its children)",
398 default=False,
400 global_scale: FloatProperty(
401 name="Scale",
402 description="Scale all data (Some importers do not support scaled armatures!)",
403 min=0.001, max=1000.0,
404 soft_min=0.01, soft_max=1000.0,
405 default=1.0,
407 apply_unit_scale: BoolProperty(
408 name="Apply Unit",
409 description="Take into account current Blender units settings (if unset, raw Blender Units values are used as-is)",
410 default=True,
412 apply_scale_options: EnumProperty(
413 items=(('FBX_SCALE_NONE', "All Local",
414 "Apply custom scaling and units scaling to each object transformation, FBX scale remains at 1.0"),
415 ('FBX_SCALE_UNITS', "FBX Units Scale",
416 "Apply custom scaling to each object transformation, and units scaling to FBX scale"),
417 ('FBX_SCALE_CUSTOM', "FBX Custom Scale",
418 "Apply custom scaling to FBX scale, and units scaling to each object transformation"),
419 ('FBX_SCALE_ALL', "FBX All",
420 "Apply custom scaling and units scaling to FBX scale"),
422 name="Apply Scalings",
423 description="How to apply custom and units scalings in generated FBX file "
424 "(Blender uses FBX scale to detect units on import, "
425 "but many other applications do not handle the same way)",
427 bake_space_transform: BoolProperty(
428 name="!EXPERIMENTAL! Apply Transform",
429 description="Bake space transform into object data, avoids getting unwanted rotations to objects when "
430 "target space is not aligned with Blender's space "
431 "(WARNING! experimental option, use at own risks, known broken with armatures/animations)",
432 default=False,
435 object_types: EnumProperty(
436 name="Object Types",
437 options={'ENUM_FLAG'},
438 items=(('EMPTY', "Empty", ""),
439 ('CAMERA', "Camera", ""),
440 ('LIGHT', "Lamp", ""),
441 ('ARMATURE', "Armature", "WARNING: not supported in dupli/group instances"),
442 ('MESH', "Mesh", ""),
443 ('OTHER', "Other", "Other geometry types, like curve, metaball, etc. (converted to meshes)"),
445 description="Which kind of object to export",
446 default={'EMPTY', 'CAMERA', 'LIGHT', 'ARMATURE', 'MESH', 'OTHER'},
449 use_mesh_modifiers: BoolProperty(
450 name="Apply Modifiers",
451 description="Apply modifiers to mesh objects (except Armature ones) - "
452 "WARNING: prevents exporting shape keys",
453 default=True,
455 use_mesh_modifiers_render: BoolProperty(
456 name="Use Modifiers Render Setting",
457 description="Use render settings when applying modifiers to mesh objects (DISABLED in Blender 2.8)",
458 default=True,
460 mesh_smooth_type: EnumProperty(
461 name="Smoothing",
462 items=(('OFF', "Normals Only", "Export only normals instead of writing edge or face smoothing data"),
463 ('FACE', "Face", "Write face smoothing"),
464 ('EDGE', "Edge", "Write edge smoothing"),
466 description="Export smoothing information "
467 "(prefer 'Normals Only' option if your target importer understand split normals)",
468 default='OFF',
470 use_subsurf: BoolProperty(
471 name="Export Subdivision Surface",
472 description="Export the last Catmull-Rom subdivision modifier as FBX subdivision "
473 "(does not apply the modifier even if 'Apply Modifiers' is enabled)",
474 default=False,
476 use_mesh_edges: BoolProperty(
477 name="Loose Edges",
478 description="Export loose edges (as two-vertices polygons)",
479 default=False,
481 use_tspace: BoolProperty(
482 name="Tangent Space",
483 description="Add binormal and tangent vectors, together with normal they form the tangent space "
484 "(will only work correctly with tris/quads only meshes!)",
485 default=False,
487 use_custom_props: BoolProperty(
488 name="Custom Properties",
489 description="Export custom properties",
490 default=False,
492 add_leaf_bones: BoolProperty(
493 name="Add Leaf Bones",
494 description="Append a final bone to the end of each chain to specify last bone length "
495 "(use this when you intend to edit the armature from exported data)",
496 default=True # False for commit!
498 primary_bone_axis: EnumProperty(
499 name="Primary Bone Axis",
500 items=(('X', "X Axis", ""),
501 ('Y', "Y Axis", ""),
502 ('Z', "Z Axis", ""),
503 ('-X', "-X Axis", ""),
504 ('-Y', "-Y Axis", ""),
505 ('-Z', "-Z Axis", ""),
507 default='Y',
509 secondary_bone_axis: EnumProperty(
510 name="Secondary Bone Axis",
511 items=(('X', "X Axis", ""),
512 ('Y', "Y Axis", ""),
513 ('Z', "Z Axis", ""),
514 ('-X', "-X Axis", ""),
515 ('-Y', "-Y Axis", ""),
516 ('-Z', "-Z Axis", ""),
518 default='X',
520 use_armature_deform_only: BoolProperty(
521 name="Only Deform Bones",
522 description="Only write deforming bones (and non-deforming ones when they have deforming children)",
523 default=False,
525 armature_nodetype: EnumProperty(
526 name="Armature FBXNode Type",
527 items=(('NULL', "Null", "'Null' FBX node, similar to Blender's Empty (default)"),
528 ('ROOT', "Root", "'Root' FBX node, supposed to be the root of chains of bones..."),
529 ('LIMBNODE', "LimbNode", "'LimbNode' FBX node, a regular joint between two bones..."),
531 description="FBX type of node (object) used to represent Blender's armatures "
532 "(use Null one unless you experience issues with other app, other choices may no import back "
533 "perfectly in Blender...)",
534 default='NULL',
536 bake_anim: BoolProperty(
537 name="Baked Animation",
538 description="Export baked keyframe animation",
539 default=True,
541 bake_anim_use_all_bones: BoolProperty(
542 name="Key All Bones",
543 description="Force exporting at least one key of animation for all bones "
544 "(needed with some target applications, like UE4)",
545 default=True,
547 bake_anim_use_nla_strips: BoolProperty(
548 name="NLA Strips",
549 description="Export each non-muted NLA strip as a separated FBX's AnimStack, if any, "
550 "instead of global scene animation",
551 default=True,
553 bake_anim_use_all_actions: BoolProperty(
554 name="All Actions",
555 description="Export each action as a separated FBX's AnimStack, instead of global scene animation "
556 "(note that animated objects will get all actions compatible with them, "
557 "others will get no animation at all)",
558 default=True,
560 bake_anim_force_startend_keying: BoolProperty(
561 name="Force Start/End Keying",
562 description="Always add a keyframe at start and end of actions for animated channels",
563 default=True,
565 bake_anim_step: FloatProperty(
566 name="Sampling Rate",
567 description="How often to evaluate animated values (in frames)",
568 min=0.01, max=100.0,
569 soft_min=0.1, soft_max=10.0,
570 default=1.0,
572 bake_anim_simplify_factor: FloatProperty(
573 name="Simplify",
574 description="How much to simplify baked values (0.0 to disable, the higher the more simplified)",
575 min=0.0, max=100.0, # No simplification to up to 10% of current magnitude tolerance.
576 soft_min=0.0, soft_max=10.0,
577 default=1.0, # default: min slope: 0.005, max frame step: 10.
579 path_mode: path_reference_mode
580 embed_textures: BoolProperty(
581 name="Embed Textures",
582 description="Embed textures in FBX binary file (only for \"Copy\" path mode!)",
583 default=False,
585 batch_mode: EnumProperty(
586 name="Batch Mode",
587 items=(('OFF', "Off", "Active scene to file"),
588 ('SCENE', "Scene", "Each scene as a file"),
589 ('COLLECTION', "Collection",
590 "Each collection (data-block ones) as a file, does not include content of children collections"),
591 ('SCENE_COLLECTION', "Scene Collections",
592 "Each collection (including master, non-data-block ones) of each scene as a file, "
593 "including content from children collections"),
594 ('ACTIVE_SCENE_COLLECTION', "Active Scene Collections",
595 "Each collection (including master, non-data-block one) of the active scene as a file, "
596 "including content from children collections"),
599 use_batch_own_dir: BoolProperty(
600 name="Batch Own Dir",
601 description="Create a dir for each exported file",
602 default=True,
604 use_metadata: BoolProperty(
605 name="Use Metadata",
606 default=True,
607 options={'HIDDEN'},
610 def draw(self, context):
611 pass
613 @property
614 def check_extension(self):
615 return self.batch_mode == 'OFF'
617 def execute(self, context):
618 from mathutils import Matrix
619 if not self.filepath:
620 raise Exception("filepath not set")
622 global_matrix = (axis_conversion(to_forward=self.axis_forward,
623 to_up=self.axis_up,
624 ).to_4x4())
626 keywords = self.as_keywords(ignore=("check_existing",
627 "filter_glob",
628 "ui_tab",
631 keywords["global_matrix"] = global_matrix
633 from . import export_fbx_bin
634 return export_fbx_bin.save(self, context, **keywords)
637 class FBX_PT_export_main(bpy.types.Panel):
638 bl_space_type = 'FILE_BROWSER'
639 bl_region_type = 'TOOL_PROPS'
640 bl_label = ""
641 bl_parent_id = "FILE_PT_operator"
642 bl_options = {'HIDE_HEADER'}
644 @classmethod
645 def poll(cls, context):
646 sfile = context.space_data
647 operator = sfile.active_operator
649 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
651 def draw(self, context):
652 layout = self.layout
653 layout.use_property_split = True
654 layout.use_property_decorate = False # No animation.
656 sfile = context.space_data
657 operator = sfile.active_operator
659 row = layout.row(align=True)
660 row.prop(operator, "path_mode")
661 sub = row.row(align=True)
662 sub.enabled = (operator.path_mode == 'COPY')
663 sub.prop(operator, "embed_textures", text="", icon='PACKAGE' if operator.embed_textures else 'UGLYPACKAGE')
664 row = layout.row(align=True)
665 row.prop(operator, "batch_mode")
666 sub = row.row(align=True)
667 sub.prop(operator, "use_batch_own_dir", text="", icon='NEWFOLDER')
670 class FBX_PT_export_include(bpy.types.Panel):
671 bl_space_type = 'FILE_BROWSER'
672 bl_region_type = 'TOOL_PROPS'
673 bl_label = "Include"
674 bl_parent_id = "FILE_PT_operator"
676 @classmethod
677 def poll(cls, context):
678 sfile = context.space_data
679 operator = sfile.active_operator
681 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
683 def draw(self, context):
684 layout = self.layout
685 layout.use_property_split = True
686 layout.use_property_decorate = False # No animation.
688 sfile = context.space_data
689 operator = sfile.active_operator
691 sublayout = layout.column()
692 sublayout.enabled = (operator.batch_mode == 'OFF')
693 sublayout.prop(operator, "use_selection")
694 sublayout.prop(operator, "use_active_collection")
696 layout.column().prop(operator, "object_types")
697 layout.prop(operator, "use_custom_props")
700 class FBX_PT_export_transform(bpy.types.Panel):
701 bl_space_type = 'FILE_BROWSER'
702 bl_region_type = 'TOOL_PROPS'
703 bl_label = "Transform"
704 bl_parent_id = "FILE_PT_operator"
706 @classmethod
707 def poll(cls, context):
708 sfile = context.space_data
709 operator = sfile.active_operator
711 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
713 def draw(self, context):
714 layout = self.layout
715 layout.use_property_split = True
716 layout.use_property_decorate = False # No animation.
718 sfile = context.space_data
719 operator = sfile.active_operator
721 layout.prop(operator, "global_scale")
722 layout.prop(operator, "apply_scale_options")
724 layout.prop(operator, "axis_forward")
725 layout.prop(operator, "axis_up")
727 layout.prop(operator, "apply_unit_scale")
728 layout.prop(operator, "bake_space_transform")
731 class FBX_PT_export_geometry(bpy.types.Panel):
732 bl_space_type = 'FILE_BROWSER'
733 bl_region_type = 'TOOL_PROPS'
734 bl_label = "Geometry"
735 bl_parent_id = "FILE_PT_operator"
736 bl_options = {'DEFAULT_CLOSED'}
738 @classmethod
739 def poll(cls, context):
740 sfile = context.space_data
741 operator = sfile.active_operator
743 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
745 def draw(self, context):
746 layout = self.layout
747 layout.use_property_split = True
748 layout.use_property_decorate = False # No animation.
750 sfile = context.space_data
751 operator = sfile.active_operator
753 layout.prop(operator, "mesh_smooth_type")
754 layout.prop(operator, "use_subsurf")
755 layout.prop(operator, "use_mesh_modifiers")
756 #sub = layout.row()
757 #sub.enabled = operator.use_mesh_modifiers and False # disabled in 2.8...
758 #sub.prop(operator, "use_mesh_modifiers_render")
759 layout.prop(operator, "use_mesh_edges")
760 sub = layout.row()
761 #~ sub.enabled = operator.mesh_smooth_type in {'OFF'}
762 sub.prop(operator, "use_tspace")
765 class FBX_PT_export_armature(bpy.types.Panel):
766 bl_space_type = 'FILE_BROWSER'
767 bl_region_type = 'TOOL_PROPS'
768 bl_label = "Armature"
769 bl_parent_id = "FILE_PT_operator"
770 bl_options = {'DEFAULT_CLOSED'}
772 @classmethod
773 def poll(cls, context):
774 sfile = context.space_data
775 operator = sfile.active_operator
777 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
779 def draw(self, context):
780 layout = self.layout
781 layout.use_property_split = True
782 layout.use_property_decorate = False # No animation.
784 sfile = context.space_data
785 operator = sfile.active_operator
787 layout.prop(operator, "primary_bone_axis")
788 layout.prop(operator, "secondary_bone_axis")
789 layout.prop(operator, "armature_nodetype")
790 layout.prop(operator, "use_armature_deform_only")
791 layout.prop(operator, "add_leaf_bones")
794 class FBX_PT_export_bake_animation(bpy.types.Panel):
795 bl_space_type = 'FILE_BROWSER'
796 bl_region_type = 'TOOL_PROPS'
797 bl_label = "Bake Animation"
798 bl_parent_id = "FILE_PT_operator"
799 bl_options = {'DEFAULT_CLOSED'}
801 @classmethod
802 def poll(cls, context):
803 sfile = context.space_data
804 operator = sfile.active_operator
806 return operator.bl_idname == "EXPORT_SCENE_OT_fbx"
808 def draw_header(self, context):
809 sfile = context.space_data
810 operator = sfile.active_operator
812 self.layout.prop(operator, "bake_anim", text="")
814 def draw(self, context):
815 layout = self.layout
816 layout.use_property_split = True
817 layout.use_property_decorate = False # No animation.
819 sfile = context.space_data
820 operator = sfile.active_operator
822 layout.enabled = operator.bake_anim
823 layout.prop(operator, "bake_anim_use_all_bones")
824 layout.prop(operator, "bake_anim_use_nla_strips")
825 layout.prop(operator, "bake_anim_use_all_actions")
826 layout.prop(operator, "bake_anim_force_startend_keying")
827 layout.prop(operator, "bake_anim_step")
828 layout.prop(operator, "bake_anim_simplify_factor")
831 def menu_func_import(self, context):
832 self.layout.operator(ImportFBX.bl_idname, text="FBX (.fbx)")
835 def menu_func_export(self, context):
836 self.layout.operator(ExportFBX.bl_idname, text="FBX (.fbx)")
839 classes = (
840 ImportFBX,
841 FBX_PT_import_include,
842 FBX_PT_import_transform,
843 FBX_PT_import_transform_manual_orientation,
844 FBX_PT_import_animation,
845 FBX_PT_import_armature,
846 ExportFBX,
847 FBX_PT_export_main,
848 FBX_PT_export_include,
849 FBX_PT_export_transform,
850 FBX_PT_export_geometry,
851 FBX_PT_export_armature,
852 FBX_PT_export_bake_animation,
856 def register():
857 for cls in classes:
858 bpy.utils.register_class(cls)
860 bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
861 bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
864 def unregister():
865 bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
866 bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
868 for cls in classes:
869 bpy.utils.unregister_class(cls)
872 if __name__ == "__main__":
873 register()