Help test improved FBX import: Reuse materials

Hi all.

I have made a small modification to the FBX import scripts of Blender.
It makes it possible to reuse existing materials already defined in the file when importing an FBX file.

I work with architectural visualisation often. I get models from CAD programs most often in the form of FBX and turn them into nice renders by tweaking the materials, light, furniture etc.
But very often (almost always), the visualisation work is early in the design process and the CAD project is always changing. I then receive an updated file and when importing that, I have to change all the materials again. And again. And again. Its very time consuming.

The small changes I made basically checks if the material in the FBX file is already in the Blender file by comparing the names of the materials. If the material is already defined that one is used. If not a new one is created.

I am not very experienced with the Blender code and I am not sure if this is the right way to do it or if I follow all coding guidelines etc. You are welcome to comment.
So if anybody could test this out and tell me if it works or if there is something I have done wrong etc.
And of course if it looks good, might it be considered for inclusion in official Blender and how?

Also, I feel this functionality is not specific for FBX only but all import/link workflows in Blender could use it. How would be the best way to maybe generalise it?

To test it, simply swap out the “io_scene_fbx” folder in the “…\scripts\addons” folder of the Blender install path. I have attached the modified version here.
Remember to make a copy of the one already there so you can change it back if you need to.

Download here from Google Drive

Best Regards
Ejnar Brendsdal

3 Likes

UPDATE:
While testing some more production files this evening this is more complex than my approach is.
I get an error when importing with more complex FBX materials as it tries to link different properties to the material upon import. But when the material is already present in the scene is does not necessarily have those properties to update.
I will look into it, but its a bit over my level.

1 Like

OMG, why this is not by default in blender…
I’m working with different 3d apps and when I reimport modified fbx file to the blender I need always switch materials to those already configured in the scene.
It’s ok when it one-two objects, but when it’s more…it turns to hell of time.

Upd:
It’s seems not working in 2.83.1+

Traceback (most recent call last):
  File "D:\!Portable Programs\blender-2.83.1-windows64\2.83\scripts\addons\io_scene_fbx\__init__.py", line 223, in execute
    if import_fbx.load(self, context, filepath=path, **keywords) == {'FINISHED'}:
TypeError: load() got an unexpected keyword argument 'use_existing_materials'

location: <unknown location>:-1:

@mont29 can you say anything about implementing this feature, if you have a time. Thx.

1 Like

This describes my day to day workflow very accurately and it would be a great feature to have built in.
Other way to look at this is to have the ability to link non-native file formats such as FBX.

Sorry can’t say what exactly goes wrong but I’m very happy to hear I’m not alone on this.
It’s a considerable amount of time I use on this.
I times it the other day. Had 5 updates in a day. Quarter of an hour each time. That’s 1.25 hours of my 7.5 hour work day. I mean, it’s the client paying but I would like to use the time on actual creative thinking instead :slightly_smiling_face:
There might be other ways to solve it but I think it’s well worth it.

1 Like