THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/10/2011 at 11:52, xxxxxxxx wrote:
I'm trying to get my head around this:
I need to duplicate Materials and keep their alpha channels and just get rid of everything else.
As I didn't find an option for just duplicating materials I just created new materials and wanted to copy the content from the active material to the new one.
I did this by using BaseList2D.GetData() and BaseList2D.SetData() -> didn't work.
So I thought of the neat BaseContainer.CopyTo() function -> the material gets duplicated, but shaders are not ... at least not in a way they are working correctly (they seem to be linked to the old material and just don't render).
Again no problem, I just duplicate the shaders. Same problem here but with an Error message:
"free render called illegaly - application stability affected"
or sometimes something about "found more than one object. try inserting one at time"
So my question is: is there an easy way to clone/duplicate materials AND their shaders (because only materials doesn't seem to work).
This is the last script I used:
def main() :
oldmat = doc.GetActiveMaterial()
newmat = c4d.BaseMaterial(oldmat.GetType())
shd = c4d.BaseList2D(oldmat[c4d.MATERIAL_ALPHA_SHADER].GetType())
newmat[c4d.MATERIAL_ALPHA_SHADER] = shd
Hopefully someone can help
On 28/10/2011 at 02:07, xxxxxxxx wrote:
You can use GetClone() to get a complete copy of a material:
def main() :
mat = doc.GetActiveMaterial()
copy = mat.GetClone()
On 28/10/2011 at 05:26, xxxxxxxx wrote:
Thanx a lot that's it, works like a charm.