THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/02/2012 at 11:55, xxxxxxxx wrote:
I've managed to convert most of my materials C++ code to python. But I'm having trouble with two things.
1.- I can't figure out how to write the SetData() function in python
2.- I can't figure out how to change the gradient's interpolation mode
#2000 = 2D-U
#2001 = 2D-V
#2002 = 2D-Diagonal
#2003 = 2D-Radial
#2004 = 2D-Circular
#2005 = 2D-Box
#2006 = 2D-Star
#2007 = 2D-FourCorner
#2008 = 3D-Linear
#2009 = 3D-Cylindrical
#2010 = 3D-Spherical
import c4d
from c4d import gui
from c4d.modules import render
def main() :
mat = doc.GetFirstMaterial()
color = c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR)#The material's color channel
shdr = mat[c4d.MATERIAL_COLOR_SHADER] #The shader inside the "texture" option
shdr[c4d.SLA_GRADIENT_TYPE]= 2000 #The "Type" option
shdr[c4d.SLA_GRADIENT_CYCLE] = True #The "Cycle" option
shdr[c4d.SLA_GRADIENT_TURBULENCE]=0 #The "Turbulence" option
shdr[c4d.SLA_GRADIENT_SPACE]= 2021 #The "Space" option
grad = shdr[c4d.SLA_GRADIENT_GRADIENT] #The gradient GUI
count = grad.GetKnotCount() #The number of gradient knots
k1 = grad.GetKnot(0) #Gets the first knot
k2 = grad.GetKnot(1) #Gets the second knot
k1['pos'] = 0.1 #Changes the first knot's position in memory only
k2['pos'] = 0.8 #Changes the second knot's position in memory only
k1['col'] = c4d.Vector(0.5, 0.1, 0.0) #Changes the first knot's color in memory only
k2['col'] = c4d.Vector(1.0 , 1.0, 1.0) #Changes the second knot's color in memory only
#grad.SetKnot(0,k1)<-------Crashes!!!
#grad[c4d.GRADIENT_INTERPOLATION]<----Wrong!!...How do you change this option?
mat.Message(c4d.MSG_UPDATE )
mat.Update( True, True )
c4d.EventAdd()
if __name__=='__main__':
main()
Can anyone shed a light on these two things?
-ScottA