Page MenuHome

"Copy Materials to Selected" only works when materials are defined on the mesh
Closed, ResolvedPublicBUG

Description

System Information
Operating system and graphics card

Blender Version
Broken: 2.79, 2.82 alpha @ 5dc1183580e932870064b44246e8fb750a8d806e

Short description of error
Copy Materials to Selected misses a copy of the materials that are linked to the object.

Exact steps for others to reproduce the error

1 open new FIle (no material in data block)
2 add cube, select cube, change name as cube1 add a "new material"
3 change material link as "object", and "un-link" the material which assgined for mesh data
( select material which linked for mesh data, in outliner, then remove link)
4 set diffuse color blue, change material name as "mat_blue"
5 add new cube, select added one, then name as "cube2"
6 select "cube2", with shift select "cube", (active object = cube1 (blue material) selected cube = cube2 (no material)
7 from material drop down menu, "copy material to others"
8 it not add material slot of cube2..

If I make material slot for cube2 and assgin new material for the slot, and "copy materials to others"
it remove material link from cube2 materia_slot. so I need manually assgin "mat_blue" for cube2 from material drop down menu.

Sorry if it is intended, but I epxect "copy material to others" work about material whch link "object" as same as link "data"

Event Timeline

Philipp Oeser (lichtwerk) lowered the priority of this task from 90 to 30.Apr 9 2018, 10:06 AM

Sorry, I might be misunderstanding, but I cannot reproduce...
Could you try this file (this has steps 1-6 of your report) and then do "copy material to others"?

If that works, then could you please post a simple .blend that has these steps in and still fails?

Marking as incomplete for now...

Thanks to check this report. andyour blend file actually worked, but it was different how set-up material, in outliner.
your attached blend file, "mat_blue" link material for "object" but at same time "mat blue" still keep link with "data" of cube1

this is my download blend.

But I report when I remove link material for "data". only link with "object"
(just change link type to object, I feel blender keep material link of "data". but I clean up it. sorry I miss discribe it)

please test with this blend, it only remove link of mat_blue with "data" but keep link with "object" which you offered blned file.
after remove link for "data", cube1 can not transfer material any more.
(but material link with object, then the cube1 can show mat_blue)

Philipp Oeser (lichtwerk) raised the priority of this task from 30 to 90.

Sorry, didnt notice the Material was still linked with data.

So yes, the Copy Material to Others operator only works with materials on object data (checked relevant code)

An alternative to using above operator is using the Make Links > Materials operator.
Afaics this operator has a couple of advantages:

  • will work with materialslots linked to objects (not objectdata)
  • will respect this user preference

couple of issues/notes with 'Copy Material to Others':

  • actually copies all materials (should be plural -- tooltip already says so)
  • wont work with materialslots linked to objects (not objectdata)
  • code history implies this was added as a (workaround?) in 2.5 in October 2009 when Make Links wasnt available, but then Make Links actually came back in November 2009

I might be missing something here, but it seems to me that (given the fact those two ops do very similar things - and one of them actually seems 'superior') we could replace Copy Material to Others with Make Links > Materials?

I'd be happy to do the patch, but kindly asking @Campbell Barton (campbellbarton) for his opinion/advice here...

Thanks advices. I could understand, Link material have many advantage, and plan to use it more.
but I may need to test it, to confrim it can be substitute of my current plan.

Because I hope to make "skin set exchanger" or "full mat exchange tool" , which can save current "all slot materials" of complex mesh as one "skin set" in another blend.file (skin_sets.blend) .
Skin_sets.blend need to store many material sets with each mesh (I plan to use duplicated link mesh) which named as each skin sets.

Then I hoped to use material which " link with object." because, "link duplicated mesh" can keep individual "skin sets". it may make blend file size small.

when I overwrite skin of current working mesh, I planed to append mesh(named as " skinset1" etc) , and copy and paste all materials. then I remove donner mesh from working scene. I planed to auto-mate these process as python add-on just for my purpose.

So if Link material work for my plan, I may need not use "copy and paste material", but as you said, actually these 2 tool seems a little different. Then I need to test it more. I think, (I am not beteran user), I may better not judge to remove old tool. if it still need for each user purpose )
and thanks test my report, and teach me about "link material" . I try it.

And,,, I really hope, if blender offer add-on, which I dsicribed above.. I know, I can easy keep material, and make material lbirary, there are already add-on for these purpose. but blender have not offered, tool or add on, which can save all material slots materials, as skin-set, and re apply it . so if you feel it seems useful, hope
you request it with clear words.
(I requested it in right-clcik select, but I could not get good response,,,)

please dont claim the task youself, this will most likely prevent others from looking at it

Philipp Oeser (lichtwerk) lowered the priority of this task from 90 to Normal.Apr 18 2018, 2:30 PM

Hi I need to re-consider this report.(and hope it confirmed) Because I understand, "Make links >material" can use to see same material (from source). and about some case it work what I expect, but there is clear difference, Between "Copy Material to Others" and "Make links (materilal)

Copy material to others can keep "material name". That means, when you make mesh with many material slot, and hope to exchange all mat at once,
"Copy material to others" can exchange materilal with keep "current material name" assgined for each material-slot.

Lets think I make complex "machine" witch have 10 material slot. And you plan to keep many material variation of the machine (keep same material-slot). And hope to exchange material-sets when you need.

  1. I save duplicated machine meshes in material.blend file. Machine1_mat1, Machine2_mat2, Machine3_mat3,,, etc.

Each "Machine_mat" are duplicated meshes of "Machine" So they use same mesh-data, and have same "material-slot",
but I can set different materials for each material slot. It only work when we set material link as "object"

  1. I hope to change machine material to Machine3_mat3. then I append Machine_mat3 to current scene, and I Copy material from Machine_mat3 to Machine. Without change Material name. But it not work (which I reported here)

3 If I use "Make Links > Materials" for "Machine" and "Machine_mat3" (which is appended from material.blend),
Machine show same materials as Machine_mat3, but it overwrite "all materials name" of Machine as same as Machine_mat3.

It is really annoying when you manage complex mesh materials assgined for material-slots.
blender do not offer way to "set name for material slots", then to keep clear, which faces are assgined for each parts material , we need to use material name.

Copy and paste Material can remove this problem. I can keep all material name , but can change material which what I hope.

Sybren A. Stüvel (sybren) changed the subtype of this task from "Report" to "Bug".Feb 4 2020, 2:34 PM
Sybren A. Stüvel (sybren) edited projects, added Modeling; removed Tracker Curfew.

Looking at the code (assign_material() and material_slot_copy_exec()) the "Copy Material to Selected" operator should work for both object & data materials.

Sybren A. Stüvel (sybren) renamed this task from "copy materials to others" not paste current active obj material, when material link as "object" to "Copy Materials to Selected" only works when materials are defined on the mesh.Feb 4 2020, 2:36 PM
Sybren A. Stüvel (sybren) updated the task description. (Show Details)

Will fix, having 100% proper fullproof solution is likely impossible given the weird mixed object/obdata relations with materials, but should usually give expected results...