Thank you very much, @i_mazlov! This is what I needed!
V
Posts made by Vladislav Borovikov
-
RE: Python - How to insert knots in c4d.Gradient
-
Python - How to insert knots in c4d.Gradient
Hello everyone!
I'm trying to add knots to the c4d.Gradient object, in GvNode. But the changes are not applied to the parameter, maybe I missed something, and this parameter needs to be updated?import c4d import redshift knots = [ (c4d.Vector(1,0,1), 0.25, 0.25, 0.25), (c4d.Vector(0,1,1), 0.5, 0.5, 0.5), (c4d.Vector(1,1,0), 0.75, 0.75, 0.75), ] def main() -> None: rs_material = doc.GetActiveMaterial() if not rs_material.GetTypeName() == "RS Shader Graph": print(rs_material.GetTypeName()) return # Get node master and root nm = redshift.GetRSMaterialNodeMaster(rs_material) root = nm.GetRoot() # Create RSRamp gvNode ramp_node = nm.CreateNode(root, 1036227) ramp_node[c4d.GV_REDSHIFT_SHADER_META_CLASSNAME] = 'RSRamp' # Get Gradient gradient = ramp_node[c4d.REDSHIFT_SHADER_RSRAMP_RAMP] gradient.FlushKnots() for i, knot in enumerate(knots): gradient.InsertKnot(knot[0], knot[1], knot[2], knot[3], i ) # Check values for i in range(gradient.GetKnotCount()): knot = gradient.GetKnot(i) col = knot.get("col") pos = knot.get("pos") br = knot.get('brightness') print(f"col = {col}, pos = {pos}, brightness = {br} ") main()