3
$\begingroup$

This question already has an answer here:

Is there any option, to append many objects without appending their materials?

Example: I have scene1.blend with cube object and wood material. I append cube with wood to scene2.blend, where there also is cube and wood material.

Blender logically creates cube.001 and wood.001, but I don't want wood.001, I need Blender to use the existing wood material instead of creating a new copy.

I'm talking about thousands of objects and hundreds materials. For example now I have natural wood.## ... natural wood.017 and all are exactly the same, and I have few dozens of materials like this multiplied by 17 object copies.

My English is not very good and this is problem little bit hard to explain, so I hope you understand what I mean.

$\endgroup$

marked as duplicate by Shady Puck, Community Jul 21 '16 at 6:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ We can understand your problem alright, but unfortunately I don't think there is any way to do this currently in Blender. I'll investigate but I have never seen a workaround. $\endgroup$ – Duarte Farrajota Ramos Jul 16 '16 at 17:55
3
$\begingroup$

After importing the objects you can use a python script to remove the use of duplicate materials. As each duplicate gets a numeric extension we can test whether the material without the extension exists and use it if it does exist.

import bpy

mat_list = bpy.data.materials

for o in bpy.data.objects:
    for s in o.material_slots:
        if s.material.name[-3:].isnumeric():
            # the last 3 characters are numbers
            if s.material.name[:-4] in mat_list:
                # there is a material without the numeric extension so use it
                s.material = mat_list[s.material.name[:-4]]
$\endgroup$
  • $\begingroup$ WOW, Exactly what I need. This script perfectly clean up my materials. Thank you very much :-) $\endgroup$ – Shubol3D Jul 18 '16 at 7:55
  • $\begingroup$ Please consider marking this answer as correct if solved your problem, or at least up-voting it if it helped you. $\endgroup$ – Duarte Farrajota Ramos Jul 20 '16 at 22:05
  • $\begingroup$ I'm sorry, I forgot. $\endgroup$ – Shubol3D Jul 21 '16 at 6:22
3
$\begingroup$

Not really a solution to the append problem directly, more of a cleanup technique, but if you only have one material per object you can easily select all objects with the same base material name (say wood.001 wood.002 wood.003) by searching for wood in the outliner.

Just go to the Outliner and search for your material name, after searching press A over the list of search results to pre-select all displayed objects in that list, then Righ-Click over them and choose Select.

That should take care of selecting all of them in the 3D view. Now in the 3D view and without deselecting the previously selected objects Shift-Select the object with the original wood you want to use to make it the Active Object.

Alternatively you may instead change the material manually to the desired original wood on any of the search results by making it the Active Object first. (Just Shift-Select one of the already selected to make it active)

Afterwards you can press Ctrl + L Link > Materials to make them all use the same wood material instead.

(Bottom line here is Link > Materials works from the active object to the selection)

$\endgroup$
  • $\begingroup$ Thanks for answer. Yes, this work, but not very useful in my case. The problem is "Shift-Select" must be done manually. Or is there way how to select all marked object at once? $\endgroup$ – Shubol3D Jul 16 '16 at 21:20
  • $\begingroup$ Yes, you can easily select them all at once, I updated my answer, check for details above. $\endgroup$ – Duarte Farrajota Ramos Jul 17 '16 at 0:24
  • $\begingroup$ I need explore Outliner features deeper :D Thank you for advice. This really helped me and it also useful for future in many cases :-) $\endgroup$ – Shubol3D Jul 17 '16 at 0:38

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