Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
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:
Hey guys. 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" ... interesting. 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()) oldmat[c4d.MATERIAL_ALPHA_SHADER].CopyTo(shd,1) newmat[c4d.MATERIAL_ALPHA_SHADER] = shd newmat.InsertShader(shd) doc.InsertMaterial(newmat)
if __name__=='__main__': main() Hopefully someone can help thanx Phil
On 28/10/2011 at 02:07, xxxxxxxx wrote:
You can use GetClone() to get a complete copy of a material:
import c4d def main() : mat = doc.GetActiveMaterial() copy = mat.GetClone() print mat print mat[c4d.MATERIAL_ALPHA_SHADER] print copy print copy[c4d.MATERIAL_ALPHA_SHADER] if __name__=='__main__': main()
On 28/10/2011 at 05:26, xxxxxxxx wrote:
Thanx a lot that's it, works like a charm. cheers Phil