Timeline for Python to Replace Skechup Material to Cycles Material
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 23, 2020 at 9:43 | comment | added | sambler |
@Mentalist My first suggestion is to start with a full list, even if the replacement is the same as the original, go into blenders python console and type bpy.data.materials.keys() to get a complete list of material names. The other option, is after the second for add if slot.material.name in matname.keys(): to only do the last command if a substitute exists. You could also put the last statement into a try block to catch errors and keep going, you only need pass in the except section.
|
|
Oct 23, 2020 at 4:12 | comment | added | Mentalist | @sambler Great answer! This was very helpful to me, as I had spent several hours struggling to write something similar. One thing I noticed and want to modify, is that while an object with materials (for example) R,G,B will get replaced with R_new, G_new, B_new... if an object has R,G_new, B, then material "B" won't get replaced because "G_new" isn't a match (it's only looking for R,G,B and stops at a non-match). Can you please teach how to skip over non-matches? | |
Sep 17, 2017 at 4:00 | comment | added | sambler |
A good start would be spending an hour or two doing a getting started tutorial like the official python tutorial. Yes matnames is a dictionary, it uses the name of the old mat as the key to retrieve the name of the new mat. Everything between {} is the contents of the dictionary, adjust the old name and new name on each line to match what you have.
|
|
Sep 16, 2017 at 16:01 | comment | added | Asaph Coimbra Fagundes | Nice! I'm new Python's user, and don't know programing :( But I trying to learn :D Thanks for all. But i have so many questions more hahahahhaa I try run this script that u posted, but don't worked :/ In the line "matnames = { .....}" u are creanting a dictionary, right? | |
Sep 16, 2017 at 11:08 | history | answered | sambler | CC BY-SA 3.0 |