Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Blender 2.79 Import Fails In 2019.1.0f1

Discussion in '2019.1 Beta' started by Karearea, Apr 12, 2019.

  1. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    I've just upgraded my project to 2019.1.0f1 from 2019.1.0b9, and all the previously functional Blender files fail to import correctly (I've been exporting to FBX manually lately, but have a couple of vestigial .blends in there).

    My Blender installation is 2.79. On starting Unity, the warning is as follows:

    Blender could not convert the .blend file to FBX file.
    You need to use Blender 2.45-2.49 or 2.58 and later versions for direct Blender import to work.
     
    BHSPitMonkey and schneckerstein like this.
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    It's important that you report these issues together with a reproduction project if you want them to get fixed. If you don't do it, it might be a long time until someone else reports them or until Unity Technologies find them.

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. You can post the Case number (number only, not the link) in this forum thread for Unity staff to pick up, in case they see it.
     
    Karearea and LeonhardP like this.
  3. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Karearea likes this.
  4. willsc8forwings

    willsc8forwings

    Joined:
    Apr 25, 2018
    Posts:
    2
    Is there any easy workaround for an existing project?
     
    schneckerstein likes this.
  5. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    There's 2 workarounds. One is to export from Blender in FBX, the other is to use the file Data\Tools\Unity-BlenderToFBX.py from the previous version of Unity.
     
    A_Savvidis, YOSSI2010 and charlesb_rm like this.
  6. YOSSI2010

    YOSSI2010

    Joined:
    Dec 26, 2016
    Posts:
    20
    Thank you very much for the workaround.

    What has changed that has caused this to happen?
    Also is there any way to trick Unity Into using blender 2.8 for the FBX export?
    Game dev with EEVEE is just amazing!
     
  7. davidson27

    davidson27

    Joined:
    Feb 10, 2018
    Posts:
    18

    Theres 2 listed work arounds here https://forum.unity.com/threads/upg...import-broken-workaround.662623/#post-4439128 by user jotapeh_

    One is to upgrade to a blender 2.8 beta.

    The other is to find the Unity-BlenderToFBX.py file from your 2018 version and replace your 2019 Unity-BlenderToFBX.py with the 2018 version.

    I compared the two files and there were some changes made to the 2019 version, but I don't know where exactly the bug is coming from.

    The solution has worked for a windows user, and a mac user (myself).
     
  8. Elhimp

    Elhimp

    Joined:
    Jan 6, 2013
    Posts:
    75
    2018.3.9f1 Unity-BlenderToFBX.py
    So you can copy-paste it now right from here (do the backup!)

    Code (Boo):
    1. blender249 = True
    2.  
    3. try: import Blender
    4. except:
    5.     blender249 = False
    6.     import bpy
    7.  
    8. if blender249:
    9.     try: import export_fbx
    10.     except:
    11.         print('error: export_fbx not found.')
    12.         Blender.Quit()
    13. else:
    14.     try: import io_scene_fbx.export_fbx
    15.     except:
    16.         print('error: io_scene_fbx.export_fbx not found.')
    17.         # This might need to be bpy.Quit()
    18.         raise
    19.  
    20. # Find the Blender output file
    21. import os
    22. outfile = os.getenv("UNITY_BLENDER_EXPORTER_OUTPUT_FILE")
    23.  
    24. # Do the conversion
    25. print("Starting blender to FBX conversion " + outfile)
    26.  
    27. if blender249:
    28.     mtx4_x90n = Blender.Mathutils.RotationMatrix(-90, 4, 'x')
    29.     export_fbx.write(outfile,
    30.         EXP_OBS_SELECTED=False,
    31.         EXP_MESH=True,
    32.         EXP_MESH_APPLY_MOD=True,
    33.         EXP_MESH_HQ_NORMALS=True,
    34.         EXP_ARMATURE=True,
    35.         EXP_LAMP=True,
    36.         EXP_CAMERA=True,
    37.         EXP_EMPTY=True,
    38.         EXP_IMAGE_COPY=False,
    39.         ANIM_ENABLE=True,
    40.         ANIM_OPTIMIZE=False,
    41.         ANIM_ACTION_ALL=True,
    42.         GLOBAL_MATRIX=mtx4_x90n)
    43. else:
    44.     # blender 2.58 or newer
    45.     import math
    46.     from mathutils import Matrix
    47.     # -90 degrees
    48.     mtx4_x90n = Matrix.Rotation(-math.pi / 2.0, 4, 'X')
    49.  
    50.     print("moo")
    51.  
    52.     class FakeOp:
    53.         def report(self, tp, msg):
    54.             print("%s: %s" % (tp, msg))
    55.  
    56.     exportObjects = ['ARMATURE', 'EMPTY', 'MESH']
    57.  
    58.     minorVersion = bpy.app.version[1];
    59.     if minorVersion <= 58:
    60.         # 2.58
    61.         io_scene_fbx.export_fbx.save(FakeOp(), bpy.context, filepath=outfile,
    62.             global_matrix=mtx4_x90n,
    63.             use_selection=False,
    64.             object_types=exportObjects,
    65.             mesh_apply_modifiers=True,
    66.             ANIM_ENABLE=True,
    67.             ANIM_OPTIMIZE=False,
    68.             ANIM_OPTIMIZE_PRECISSION=6,
    69.             ANIM_ACTION_ALL=True,
    70.             batch_mode='OFF',
    71.             BATCH_OWN_DIR=False)
    72.     else:
    73.         # 2.59 and later
    74.         kwargs = io_scene_fbx.export_fbx.defaults_unity3d()
    75.         io_scene_fbx.export_fbx.save(FakeOp(), bpy.context, filepath=outfile, **kwargs)
    76.     # HQ normals are not supported in the current exporter
    77.  
    78. print("Finished blender to FBX conversion " + outfile)
     
    Vincent454 and Karearea like this.
  9. Vincent454

    Vincent454

    Joined:
    Oct 26, 2014
    Posts:
    167
    No idea why, but your code didn't work for me, I installed 2018.3 again and this one worked:
    Code (CSharp):
    1. import bpy
    2. blender249 = True
    3. blender280 = (2,80,0) <= bpy.app.version
    4.  
    5. try:
    6.     import Blender
    7. except:
    8.     blender249 = False
    9.  
    10. if not blender280:
    11.     if blender249:
    12.         try:
    13.             import export_fbx
    14.         except:
    15.             print('error: export_fbx not found.')
    16.             Blender.Quit()
    17.     else :
    18.         try:
    19.             import io_scene_fbx.export_fbx
    20.         except:
    21.             print('error: io_scene_fbx.export_fbx not found.')
    22.             # This might need to be bpy.Quit()
    23.             raise
    24.  
    25. # Find the Blender output file
    26. import os
    27. outfile = os.getenv("UNITY_BLENDER_EXPORTER_OUTPUT_FILE")
    28.  
    29. # Do the conversion
    30. print("Starting blender to FBX conversion " + outfile)
    31.  
    32. if blender280:
    33.     import bpy.ops
    34.     bpy.ops.export_scene.fbx(filepath=outfile,
    35.         check_existing=False,
    36.         use_selection=False,
    37.         use_active_collection=False,
    38.         object_types= {'ARMATURE','CAMERA','LIGHT','MESH','EMPTY'},
    39.         use_mesh_modifiers=True,
    40.         mesh_smooth_type='OFF',
    41.         use_custom_props=True,
    42.         apply_scale_options='FBX_SCALE_ALL')
    43. elif blender249:
    44.     mtx4_x90n = Blender.Mathutils.RotationMatrix(-90, 4, 'x')
    45.     export_fbx.write(outfile,
    46.         EXP_OBS_SELECTED=False,
    47.         EXP_MESH=True,
    48.         EXP_MESH_APPLY_MOD=True,
    49.         EXP_MESH_HQ_NORMALS=True,
    50.         EXP_ARMATURE=True,
    51.         EXP_LAMP=True,
    52.         EXP_CAMERA=True,
    53.         EXP_EMPTY=True,
    54.         EXP_IMAGE_COPY=False,
    55.         ANIM_ENABLE=True,
    56.         ANIM_OPTIMIZE=False,
    57.         ANIM_ACTION_ALL=True,
    58.         GLOBAL_MATRIX=mtx4_x90n)
    59. else:
    60.     # blender 2.58 or newer
    61.     import math
    62.     from mathutils import Matrix
    63.     # -90 degrees
    64.     mtx4_x90n = Matrix.Rotation(-math.pi / 2.0, 4, 'X')
    65.  
    66.     class FakeOp:
    67.         def report(self, tp, msg):
    68.             print("%s: %s" % (tp, msg))
    69.  
    70.     exportObjects = ['ARMATURE', 'EMPTY', 'MESH']
    71.  
    72.     minorVersion = bpy.app.version[1];
    73.     if minorVersion <= 58:
    74.         # 2.58
    75.         io_scene_fbx.export_fbx.save(FakeOp(), bpy.context, filepath=outfile,
    76.             global_matrix=mtx4_x90n,
    77.             use_selection=False,
    78.             object_types=exportObjects,
    79.             mesh_apply_modifiers=True,
    80.             ANIM_ENABLE=True,
    81.             ANIM_OPTIMIZE=False,
    82.             ANIM_OPTIMIZE_PRECISSION=6,
    83.             ANIM_ACTION_ALL=True,
    84.             batch_mode='OFF',
    85.             BATCH_OWN_DIR=False)
    86.     else:
    87.         # 2.59 and later
    88.         kwargs = io_scene_fbx.export_fbx.defaults_unity3d()
    89.         io_scene_fbx.export_fbx.save(FakeOp(), bpy.context, filepath=outfile, **kwargs)
    90.     # HQ normals are not supported in the current exporter
    91.  
    92. print("Finished blender to FBX conversion " + outfile)
    93.