Home Technical Talk

[Blender] FBX Bundle Export addon

sublime tool
Offline / Send Message
renderhjs sublime tool
I just released my second Blender addon called 'FBX Bundle'. It splits selected objects into bundles and allow to export each as its own FBX file. That's the core functionality, everything else is just to support that workflow.


Download & Documentation

Features

  • Batch Export selected objects as FBX bundles
  • Batch Import 3D files from a folder (fbx, obj, 3ds)
  • Templates for Unity, Unreal and Blender
  • Preview bundles as you select objects
  • Bundle objects by name, group, material or scene
  • Fix Unity rotation, scale and material issues
  • Draw fences around bundles of objects
  • Align pivots to common ground



Drawing Fences

Draws grease pencil lines around your selected object bundles.

  • The border uses the padding from the settings
  • The pole represents the bundle origin when exporting FBX files
  • A thin grid is drawn to seperate objects within a bundle


Ground Pivot

Sets the pivot points of selected objects to the ground of the bounding box of the bundle.


Working with Unity

The addon comes with an Unity Editor script which automatically resets the -90 degree rotations and assigns existing materials automatically if the name assigned in blender matches any material name in your Unity project. This script is completely optional and not mandatory at all.


The Unity Editor script can automatically assign existing materials if the material names between Blender and the Unity project match.



This is an addon that I always wanted for 3dsMax or Blender, a painless stupid simple way to export and update existing FBX files in a project. I have been using variants of this script in the past at work on commercial projects and it saves so much time, all you do is select your objects and press 'Export'.

Replies

  • kio
    Offline / Send Message
    kio polycounter lvl 16
    This is looking very cool, one thing I added in my 3ds max exporter which I feel would be useful is the ability to define the origin of each group. I just used a point helper which had to follow a naming convention.

    If you work on tiling modules it can be very annoying if your pivot floats around each time you export.

    Just an idea, cool stuff :)
  • Idlero
    Offline / Send Message
    Idlero polycounter lvl 10
    @renderhjs Great job 
    could you change for unreal preset?:
    apply_scale_options = 'FBX_SCALE_ALL'
    to 
    apply_scale_options = 'FBX_SCALE_NONE',

  • csprance
    Offline / Send Message
    csprance polycounter lvl 13
    This is pretty neat.

    You've really been taking off with the blender scripting stuff.

    I've been thinking of learning blender specifically for the tool scripting side of it since I hear lots of nice things about it.

    How would you rate blenders "script-ability" compared to max? Seems like everything about blender is designed around the idea that it can be scripted/automated which is a novel idea. 


    Keep up the great work so I can come along and look at your code :smile: and learn something

  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    @kio said:
    This is looking very cool, one thing I added in my 3ds max exporter which I feel would be useful is the ability to define the origin of each group. I just used a point helper which had to follow a naming convention.
    If you work on tiling modules it can be very annoying if your pivot floats around each time you export.
    Will brain storm about the idea, ideally a mechanic that makes naturally sense as opposed to a hardcoded name identifier etc. Thanks for the input.

    Idlero
    could you change for unreal preset?:
    apply_scale_options = 'FBX_SCALE_ALL',
    to apply_scale_options = 'FBX_SCALE_NONE',
    I have been installing Unreal Engine again to experiment with export, scale and rotation settings. Once I have confirmed myself how Unreal engine treats FBX files I will update the preset values for the Unreal engine target.


    On another note I have started creating a logo design for this addon, to give it a bit visual love


    For an upcoming version I am looking into a LOD pipeline or something to save variants of bundles with modifiers applied that are copied from a target object.
  • Nosslak
    Offline / Send Message
    Nosslak polycounter lvl 12
    Great script! I've been using it for a bit today and have a few suggestions:
    1. Could we get an option to set the pivot of the exported mesh to be aligned to the topmost parent object in a hierarchy?
    2. When you select the parent or group bundling method could you automatically export everything linked to the selected object (be it in a group or hierarchy? I would like to only need to select a single object in the hierarchy/group and then have the script export everything else along with it when I press the button.

    In regards to the last point it sounds like that's the intended purpose of those bundle options but they don't seem to work like that for me, but I could be doing something wrong or I could be misunderstanding their purpose.
  • TheGabmeister
    Offline / Send Message
    TheGabmeister interpolator
    Just tried the addon. Great stuff. Makes batch exporting of single objects a lot easier.

    I agree with @Nosslak on his first point. After some testing with objects with multiple children, I was unable to to set the pivot of the exported mesh to be aligned to the topmost parent object in the hierarchy.

    Also, there seems to be a minor rotation issue with the child objects when testing in Unity 2018.1.7 as can be seen in the screenshots below: 



    When exported into Unity, all the child objects are rotated by -90 degrees along X-axis by default. 



    This can be quickly fixed by resetting the rotation of all the child objects in the editor.
  • Idlero
    Offline / Send Message
    Idlero polycounter lvl 10
    @Nosslak, @TheGabmeister lately i prepare change that allow to set pivot at parent location it's waiting for pull to the repostitory. Its very useful feature

    https://bitbucket.org/renderhjs/blender-addon-fbx-bundle/pull-requests/3/added-set-pivot-at-parent-location/diff
  • Nosslak
    Offline / Send Message
    Nosslak polycounter lvl 12
    @Idlero That's great, will give it a go when I get home. Thanks!
  • Nosslak
    Offline / Send Message
    Nosslak polycounter lvl 12
    Idlero said:
    @Nosslak, @TheGabmeister lately i prepare change that allow to set pivot at parent location it's waiting for pull to the repostitory. Its very useful feature

    https://bitbucket.org/renderhjs/blender-addon-fbx-bundle/pull-requests/3/added-set-pivot-at-parent-location/diff
    Everything seems to work as expected when you have a mesh with either an empty or another mesh as the parent. However when you only have a single mesh without any parents or children, the script throws up an error, it would probably be pertinent to just use the name and pivot of the lone selected object instead. Other than that it's all good!
  • Idlero
    Offline / Send Message
    Idlero polycounter lvl 10
    Nosslak said:
    Everything seems to work as expected when you have a mesh with either an empty or another mesh as the parent. However when you only have a single mesh without any parents or children, the script throws up an error, it would probably be pertinent to just use the name and pivot of the lone selected object instead. Other than that it's all good!

    It's known issue. I was waiting for response from @renderhjs with any fixes or changes.
    any way I will fix that today on my branch
     
    update:
    https://bitbucket.org/renderhjs/blender-addon-fbx-bundle/pull-requests/3/added-set-pivot-at-parent-location/diff
    @Nosslak  
    changed behavior ;)  should be fine now

  • Idlero
    Offline / Send Message
    Idlero polycounter lvl 10
    recently i notice that export preset for unreal is wrong and unreal give warning about smoothing groups
    mesh_smooth_type should be set to FACE on export 
    I fixed that in my repo, committed that to pull request:
    https://bitbucket.org/renderhjs/blender-addon-fbx-bundle/pull-requests/3/added-set-pivot-at-parent-location/diff
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    1. Could we get an option to set the pivot of the exported mesh to be aligned to the topmost parent object in a hierarchy?
    This has been implemented with version 1.2.0 thanks to idlero's  pull request


    2. When you select the parent or group bundling method could you automatically export everything linked to the selected object (be it in a group or hierarchy? I would like to only need to select a single object in the hierarchy/group and then have the script export everything else along with it when I press the button.
    That's an interesting idea, its not currently support but I will look into a way to add it as an option ("include all parent children").
    Personally I sometimes link or parent objects I don't wish to export e.g. boolean objects used in modifiers but that I still might want to parent as they should move with the parent.



    Also, there seems to be a minor rotation issue with the child objects when testing in Unity 2018.1.7 as can be seen in the screenshots below: 
    I believe that with version 1.1.0 you did not use the provided Editor script for Unity (can be found in the FBX bundle addon preferences). The script would fix the object rotation on the Unity side.


    Fortunately this is now even easier and does not require the Unity Editor script for the rotations \o/. A pull request by tanitta which uses now the blender 'bake_space_transform' experimental feature directly in the FBX export addon. Very nice pull request description he provided!


    Everything seems to work as expected when you have a mesh with either an empty or another mesh as the parent. However when you only have a single mesh without any parents or children, the script throws up an error, it would probably be pertinent to just use the name and pivot of the lone selected object instead. Other than that it's all good!
    I actually fixed that, I applied rotations in Unity when collapsing objects into a single mesh and that fixed it


    recently i notice that export preset for unreal is wrong and unreal give warning about smoothing groups
    mesh_smooth_type should be set to FACE on export 
    Yes I merged that now - had some confusing information when I tried to research this setting on the internet as some suggested to have 'OFF' instead. But I turned it 'FACE' for Unity and Unreal now.
    Thanks so much for your input. I might have been busy but I finally merged it all.
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool

    Version 1.2.0 is out!!

    Documentation & Source
    Download 1.2.0



    Pull Requests

    For this version I received 3 pull requests by members from this forum and outside. They are:
    1. Set pivot at parent location by Idlero. Great feature thanks again!
    2. bake space transform by tanitta. Very nice documentation of the changes - I actually made it the default behavior for Unity as it removes the need for the Unity Editor script to nullify the rotations on the unity side of the containers.
    3. Fixed scale problem in UNREAL by Shuhei Toyoda. This fixes the scale for Unreal engine export.

    Changes

    • New pivot mode: parent pivot
    • Batch import improvements: Catch except for unsupported FBX files (e.g. ASCII FBX assets)
    • Improved Unreal & Unity export settings (scale, units, smoothing groups)
    • Fixed scale for Unreal export
    • Install / uninstall errors fixed
    • New mesh fix tool: Clean up smoothing, uv & topology issues on selected objects
    • Animation detection (keyframes, armature,..) which will avoid collapsing objects to not break animations for export 
    • Updated Unity Editor script: No more need to modify object rotations on the Unity side. Optional script now only matches materials in Unity by material name in Blender.


    Upcoming feature: Modifiers

    This is something I am working on currently and that I would like to have ready for the next version



    Its a non destructive modifier system for the FBX bundles with modular modifiers that can easily be extended in python. Each time you export these modifiers can intercept the about to be exported objects and alter them.

    Some of the modifiers that I am looking into:
    • Merge: Merge all objects of the bundle, merge by material etc.
    • Copy modifiers: Have a reference object where all its blender modifiers are copied and applied for the bundle's objects. This can be useful for some custom mesh compressions.
    • LOD: options for generating LOD objects and bundling within the bundle or as separate files. Both Unity and Unreal have different conventions but the idea would be to automate this with settings for each LOD group.
    • Collider: Generate collider meshes for objects inside the bundle or for the bundle
    • Rename: rename objects of the bundle before exporting. This could be useful to inject custom variables or simplify names for the exported files.

    Again still working on this and there are still technical hurdles to solve - but I think that these modifiers will be a great way to boost asset creation.
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    Upcoming new tool "Pack bundles"

    Does a binary packing on the selected bundles (not just per object but per bundle). This GIF shows a batch import on assets and then a packing to arrange them in the scene. I am using the 'by parent' sorting mode as none of them have a parent to isolate them by object.


  • TheGabmeister
    Offline / Send Message
    TheGabmeister interpolator
    Awesome! Just tested on Unity 2018.1.7. Works great on my use cases which are mostly static objects. No issues encountered so far.
  • Frankie
    Offline / Send Message
    Frankie polycounter lvl 20
    I just had a go, seems really nice but missing a way to include an armature in the export, resulting in unity importing "mesh renderer" instead of "skinned mesh renderer"

    Also would be handy for me to have a button to export all objects in current scene instead of having to select them.

  • LuisCherubini
    Offline / Send Message
    LuisCherubini interpolator
    Neat stuff, I'll be making a video of this soon. 
    I'll see how it compares with Capsule from Takanu Kyriako.


  • Michael Knubben
    Hey @renderhjs , any chance this could support other formats soon? At work we're preparing to use gltf for our custom engine (as well as online stuff), and it'd be nice to be able to use this in the pipeline!
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    Hey @renderhjs , any chance this could support other formats soon? At work we're preparing to use gltf for our custom engine (as well as online stuff), and it'd be nice to be able to use this in the pipeline!
    I presume that would be fairly easy, just started downloading the official glTF addon. How about I add a target - you test and use it and give feedback. Curious about the glTF for substance and other targets myself as well.

    Edit: Some progress this evening

    Will have to add a warning if the glTF addon is not installed.
  • Michael Knubben
    Sounds good! The engine itself is still some ways off, but I can definitely test some assets.
  • bitinn
    Offline / Send Message
    bitinn polycounter lvl 6
    Hi @renderhjs, just quick check: has this tool been tested with macOS?

    The export/open folder buttons are triggering this error with v1.2.0 release

    Traceback (most recent call last):

      File "/Users/df/Library/Application Support/Blender/2.79/scripts/addons/FBXBundleExporter/op_file_export.py", line 32, in execute

        export(self, bpy.context.scene.FBXBundleSettings.target_platform)

      File "/Users/df/Library/Application Support/Blender/2.79/scripts/addons/FBXBundleExporter/op_file_export.py", line 162, in export

        bake_space_transform = bake_transform

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/modules/bpy/ops.py", line 189, in __call__

        ret = op_call(self.idname_py(), None, kw)

    RuntimeError: Error: Traceback (most recent call last):

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/__init__.py", line 620, in execute

        return export_fbx_bin.save(self, context, **keywords)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 3113, in save

        ret = save_single(operator, context.scene, filepath, **kwargs_mod)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 3020, in save_single

        fbx_objects_elements(root, scene_data)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 2819, in fbx_objects_elements

        fbx_data_mesh_elements(objects, me_obj, scene_data, done_meshes)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 941, in fbx_data_mesh_elements

        me.polygons.foreach_get("use_smooth", t_ps)

    TypeError: couldn't access the py sequence


    location: /Applications/blender.app/Contents/Resources/2.79/scripts/modules/bpy/ops.py:189




    location: <unknown location>:-1


    Traceback (most recent call last):

      File "/Users/df/Library/Application Support/Blender/2.79/scripts/addons/FBXBundleExporter/op_file_export.py", line 32, in execute

        export(self, bpy.context.scene.FBXBundleSettings.target_platform)

      File "/Users/df/Library/Application Support/Blender/2.79/scripts/addons/FBXBundleExporter/op_file_export.py", line 162, in export

        bake_space_transform = bake_transform

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/modules/bpy/ops.py", line 189, in __call__

        ret = op_call(self.idname_py(), None, kw)

    RuntimeError: Error: Traceback (most recent call last):

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/__init__.py", line 620, in execute

        return export_fbx_bin.save(self, context, **keywords)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 3113, in save

        ret = save_single(operator, context.scene, filepath, **kwargs_mod)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 3020, in save_single

        fbx_objects_elements(root, scene_data)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 2819, in fbx_objects_elements

        fbx_data_mesh_elements(objects, me_obj, scene_data, done_meshes)

      File "/Applications/blender.app/Contents/Resources/2.79/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 941, in fbx_data_mesh_elements

        me.polygons.foreach_get("use_smooth", t_ps)

    TypeError: couldn't access the py sequence


    location: /Applications/blender.app/Contents/Resources/2.79/scripts/modules/bpy/ops.py:189




    location: <unknown location>:-1


    Traceback (most recent call last):

      File "/Users/df/Library/Application Support/Blender/2.79/scripts/addons/FBXBundleExporter/op_file_open_folder.py", line 33, in execute

        os.startfile(path)

    AttributeError: module 'os' has no attribute 'startfile'


    location: <unknown location>:-1


  • TheGabmeister
    Offline / Send Message
    TheGabmeister interpolator
    @renderhjs, I think I found a bug. When exporting an object that uses a naming convention with Pascal Case or Underscores, the resulting name of the FBX file is incorrect. In the screenshots below, "CubeSmall" becomes "Cube" and "Cube_Small" becomes "Cube_".




  • motionblur
    Offline / Send Message
    motionblur polycounter lvl 12
    Super cool addon. This makes working with Unity a lot faster and much more fun. Thank you very, very much! :smiley:

    Do you think it would be possible to add an optional size multiplier for export, though?
    I'm working on rather small models frequently and Blender doesn't sem to be that good in handling small scales. So I have to scale them up and re-scale them for export again (then undo).
    An optional checkbox "modify size factor for export" would be super cool!
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    ...Do you think it would be possible to add an optional size multiplier for export, though?
    I'm working on rather small models frequently and Blender doesn't sem to be that good in handling small scales. So I have to scale them up and re-scale them for export again (then undo). An optional checkbox "modify size factor for export" would be super cool!
    Thanks for the input - that actually sparked an idea. The way I implemented this is via a Offset Transform modifier. You assign a source object (e.g. Plain axis Empty) and any location, rotation and scale offsets are applied to each bundle upon export.


    This way you can actually offset rotations, apply scales etc. automatically.

    Upcoming Update

    A big update for FBX Bundle is around the corner with a lot of new features and a big overhaul on how different target platforms are supported (much more modular). In the last few days I have been creating a new website to document the new features


  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    @renderhjs, I think I found a bug. When exporting an object that uses a naming convention with Pascal Case or Underscores, the resulting name of the FBX file is incorrect. In the screenshots below, "CubeSmall" becomes "Cube" and "Cube_Small" becomes "Cube_".
    Thanks for the bug report. I managed to fix the bug, here is a preview of the fix

  • Carpe
    Hey, Great job on the add on it's a life saver but I have one small suggestion. Is it possible to have the option to have the fbx exported out into it's own named folder. This will help when you're creating asset bundles in Unity. Many Thanks.
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    Carpe said:
    Hey, Great job on the add on it's a life saver but I have one small suggestion. Is it possible to have the option to have the fbx exported out into it's own named folder. This will help when you're creating asset bundles in Unity. Many Thanks.
    Thanks for the feedback, I started adding one more modifier called 'Rename' to address this.

    The idea is that you can modify either the path / folder and the file name using dynamic variables and any string you feel like. Once functional you would be able to create folders per bundle that way.
    The following variables I am working on:
    • {path} the original output path
    • {bundle} the bundle name
    • {scene} the current scene name
    It will preview in realtime the new bundle names within the modifier UI
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool

    FBX Bundle 1.5.0 is out!


    new website & download
    http://renderhjs.net/fbxbundle/



    Changes
    • New modifiers system:  Any of  these active export modifiers are applied upon export
    • New platform system: Unity, Unreal, Collada, glTF
    • glTF support (requires official glTF addon)
    • New pivot mode: Empty plain axis object.
    • Include children: Auto select grouped objects e.g. in scene mode, group mode, parent mode

    • Re-Export button: Re-Exports previous objects again

    New Modifiers

    • Rename: Allows to rename the target path or bundle file name. These fields support dynamic variables, dynamic variables are written inside curly brackets { } .

    • Offset transform: Copies the transform offset (moverotatescale) of a source object to each item in the bundle.
    • Copy Modifiers: Copies blender modifiers from a source object to all exported objects. For example your source object could contain a triangulate or edge split modifier which would be applied on each object upon export.
    • Merge Meshes: Merges all meshes of a bundle into a single mesh and object. This modifier is ideal for static environment assets.

    • Collider Meshes: Creates an additional collider mesh for each object in a bundle with a simplified geometry.

    • LOD: Also known as level of detail which is a technique used in game engines to optimize performance. This modifier creates a series of copies of each object in your bundle with a reduced triangle count for each LOD step and a name indicating the LOD level.

      LOD levels are previewed in the modifier panel with the compression ratio and LOD level.
    • Vertex AO: This modifier applies vertex color based ambient occlusion to each mesh of a bundle. This is a great way of adding AO depth without the limitation of texture resolution, file or memory size of textures.

      Vertex colors require shaders to fully utilize them.

  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    Mike from Grame from Scratch post a video up on his YouTube channel where he runs down the features. When I get the time I'll make a video myself with a actual demo.

  • pixelb
    Offline / Send Message
    pixelb greentooth
    How about a modifier to override the assigned material(s)? Case in point, I use cycles materials to preview my texture blending in Blender but I need to turn off nodes every time I batch export or else the models don't come in with textures assigned.
  • renderhjs
    Offline / Send Message
    renderhjs sublime tool
    pixelb said:
    How about a modifier to override the assigned material(s)? Case in point, I use cycles materials to preview my texture blending in Blender but I need to turn off nodes every time I batch export or else the models don't come in with textures assigned.
    Good idea, didn't think of that before. Perhaps a modifier for materials in general, e.g. remove all materials when exporting or override them like you suggested.

    With 2.8 around the corner it would be nice to also implement sorting or converting to collections, e.g. bundle objects by collection. And with 2.8 the GlTF addon will be part of Blender which makes it easier for me to include the support (it already does now but requires a manual install of the addon).
  • energUImen0
    Hi, first just say thanks for the awesome add-on, is has made my life a lot easier. I just have a question i can't find and answer for anywhere. Is there a way to preserve the parent/child relation of objects when exporting to unity?  I might be missing the obvious but the object hierarchy gets flattened and then you need to reparent everything inside unity.  Is this a limitation of the add-on or am i doing it wrong?
  • TheGabmeister
    Offline / Send Message
    TheGabmeister interpolator
    Now that the stable release of Blender 2.8 is finally out, I'm eagerly waiting for this addon to be compatible :)
  • Tosyk
    Offline / Send Message
    Tosyk polycounter lvl 13
    thanks for the addon guys, I wonder where to find it in 2.8 blender? I couldn't even find Tools Panel
    eidt: turns out I need downgrade blender in order to use it (
Sign In or Register to comment.