On 14/02/2018 at 01:05, xxxxxxxx wrote:
Hi all,
I am scripting a simple photostudio Helper which has a simple color gradient as backdrop.
Anyway my userdata has a gradient controller which is copied into a material channnel.
The Problem: hence of the event update its updating everytime.
Question: Can i copy the existing gradient and compare it to the userdata and only update if something has changed ?
i tried this with no luck.
if op[c4d.ID_USERDATA,53] != sha[c4d.SLA_GRADIENT_GRADIENT]:
any idea how to manag this "update"
here is the function:
def insertshader (op) :
if doc.SearchMaterial('ops Backdrop Gradient') != None: # Falesafe if somebody renames or deletes the shader
gra = op[c4d.ID_USERDATA,53]
sha = c4d.BaseShader(c4d.Xgradient)
sha[c4d.SLA_GRADIENT_GRADIENT] = gra #c4d.SLA_FRESNEL_GRADIENT
mat = doc.SearchMaterial('ops Backdrop Gradient')
mat.InsertShader(sha)
mat[c4d.MATERIAL_COLOR_SHADER] = sha
mat.Message(c4d.MSG_UPDATE)
mat.Update(True, True)
else:
print "Did not find shader named: ops Backdrop Gradient"
thanks for your time.