On 24/07/2017 at 08:13, xxxxxxxx wrote:
Here a code I did 6 months ago. So it's not the cleanest but it's working and since this subject is not very well documented I guess It gonna help you
def setAlpha(self,path,shader) :
if path.endswith( ('.psd' , '.PSD') ) : #PSD
bc = c4d.BaseContainer()
tex = c4d.modules.bodypaint.SendPainterCommand(c4d.PAINTER_LOADTEXTURE, doc=self.doc, tex=None, bc=bc)
if tex is False:
layer = tex.GetFirstLayer()
layerName = layer.GetName()
layermode = c4d.LAYERSETMODE_LAYERALPHA
c4d.modules.bodypaint.SendPainterCommand(c4d.PAINTER_FORCECLOSETEXTURE, doc=self.doc, tex=tex, bc=c4d.BaseContainer())
else:#tiff, But if you already know the name simply use this
layerName = 'Alpha'
layermode = c4d.LAYERSETMODE_ALPHAS
layerSet = c4d.LayerSet()
shader[c4d.BITMAPSHADER_LAYERSET] = layerSet
If it's an psd it load it and have a c4d.modules.bodypaint.PaintTexture object.
Then now you are able to list all the layer. I my case I always used the first layer, but you can loop using GetNext/GetDown, in other way if you already know the name of the layer simply use the exemple for the tiff
Then after you just have to create a LayerSet and set thoses data.
Hope it's helped