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

11 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.

2 Likes

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.

3 Likes

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.

4 Likes

@EjnarBrendsdal
Hi, great functionality which should be added to all importers. I wanted to try your addon, but the “import_fbx.py” file is missing. Do you have a version which runs with new blender?

Files need to be copied into blender core folder.
But do not do that. It’s not working.

I asked @mont29 over one year ago to comment about this implementation… but no luck.

2 Likes

Can you specify what CAD programs do you use?
As far as remember, there is no way to get materials and textures from Revit, since they are hardcoded in not documented part of a FBX format.
Bastien tried to dig through this some time ago, but with no success.

1 Like

I’m using revit. I always wondered why blender doesn’t import materials from revit FBX export while 3ds max does. So this explains it. I’m using twinmotion exporter which keeps materials and has some options for object grouping.
I’d like to get a workflow like 3ds max has where one can link FBX which then can be reloaded and keep 3ds max materials. With reuse materials I could almost get there.

1 Like

Same here.
I’m using Twinmotion exporter and then the special materials addon to quickly “merge base names” when I reimport the FBX.
Its a hack but it’s very close as long as you don’t edit the UVs of the Revit mesh.

What addon do you use? Is it “Material Utilities”? I found it very useful, also for this case.

We are using 3dsmax, getting Autodesk AEC™ materials after import, which cannot be exported, and then using maxscript to convert all the materials from AEC to exportable Standard.
Keeping smiling and loving propietary pipelines.

Archicad for example provides nice textured obj.

1 Like

Exactly. I don’t know why but I only found it after using blender for a decade and I don’t know what I would do without it.

Sounds familiar.
What Material Utilities does?

Specials

  • Merge Base Names
    Finds materials such as Material, Material.001, Material.002 and merges them into a single material (Material).

Very convenient menu from 3dView.

3 Likes

Aw, so it works like Mats Unclone from our 1D_Scripts)
Do they have analogue of a Mats Funclone, when materials of an active object became dominant independently of suffix?

I only know

  • Replace Material
    Replace any occurence of one material, Original, with another material, Replacement.
    In the operator panel you can also choose if you want it done “globally” (for all objects in the file), or just for selected objects.
    You can also choose to have the objects that were affected by the change selected (objects not affected will be deselcted).
    Replace Material

It also solvable with unclone, you need to call the materials that you want to turn into GLASS as GLASS.00 and run Unclone operator. Works only globally though)

I only missing feature “Sort material slots by name”.
It is in filtering option - but it’s only visual for blender, not for exporting…

1 Like

Yes, we use it, very useful.
Also have functions for syncronising materials lists between objects, including order.