0
$\begingroup$

is it possible that Blender don't add numbers behind the materials when I import a FBX? Because right now I have the problem, that I have to change the material for every window in the scene.

For example, the normal Name for Glas.120 should only be Glas.

Thanks for your help.

enter image description here

$\endgroup$
  • 4
    $\begingroup$ To clarify, it's not adding number to name, it's adding a new material each time. Just like objects, if you add a new one with same name, it gets number extension. There was a post recently on consolidating all materials to one, "xxx.nnn" -> "xxx". remove duplicate materials $\endgroup$ – batFINGER Sep 30 '17 at 14:54
2
$\begingroup$

Hopefully, using a Material Specials addon could do the job for you:

  1. Enable it in User Preferences (CtrlAltU) > Addons.

    enter image description here

  2. After you import your model, use the slots menu by clicking the arrow down button (beside material slots list) and navigate to Specials > Merge Base Names

    enter image description here

  3. Set AutoRename and click OK, it should remove .00X from all materials (not only for selected object)

    enter image description here

    If you get multiple materials with the same name, you can try Clean Material Slots function:

    enter image description here

$\endgroup$
1
$\begingroup$

To clarify, it's not adding number to name, it's adding a new material each time. Just like objects, if you add a new one with same name, it gets number extension.

As an alternative, for those that don't wish to use material specials addon, a simple little cleaner script.

To elaborate on the answer to consolidating all materials to one, "xxx.nnn" -> "xxx". in disable material duplication

after you have imported an FBX all imported objects are in the context.selected_objects collection. Not all of these will have materials. A more brute strength approach would be using the scene.objects collection, which is all objects in scene.

Code from answer modified to be run directly after import, that is while the newly imported objects are selected. Copy script and paste in text block, then run script to remove dupe materials only from the objects newly imported..

import bpy
context = bpy.context
scene = context.scene
mats = bpy.data.materials

for obj in context.selected_objects: # selected context.scene.objects:
    # all objects have material_slots
    for slot in obj.material_slots:
        part = slot.name.rpartition('.')
        mat =  mats.get(part[0])
        if part[2].isnumeric() and mat is not None:
            slot.material = mat
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.