Since 2.82 CurveMap has no 'evaluate' method anymore?

I use a shaderNodeRGBCurve in my add on to control some profiles. To read the curve i use something similiar to y=curve.evaluate(x)
this worked fine until 2.81, but since 2.82 i get an error message that " ‘CurveMap’ object has no attribute ‘evaluate’ "
Is there any fellow Blendercoder who can point me in the right direction? Does anyone have an idea what changed, or where to find some documentation on this?

I don’t know if that helps, but from looking at the documentation, there seems to be a CurveMapping object that calls evaluate with a curve as argument: https://docs.blender.org/api/current/bpy.types.CurveMapping.html#bpy.types.CurveMapping.evaluate So maybe somethig like curve_mapping.evaluate(curve, x) would work? No idea how to get this CurveMapping object though

1 Like

yes, thanks. the api changed (of course, hence the issue)
now the evaluate is as you said. and the curvemapping is the container which holds the different curves (for example the shadernodeRGBcurve has 4 curves for r,g,b, and composite)

so a small codesnippet that works in 2.82 would be for example:

import bpy
bpy.data.node_groups.new(‘myCurve’, ‘ShaderNodeTree’) #creating nodegroup as container
nt=bpy.data.node_groups[‘myCurve’] #call the nodegroup nt
cn = nt.nodes.new(‘ShaderNodeRGBCurve’) #add a rgbcurve into the nodegroup
myCurveMapping = bpy.data.node_groups[‘myCurve’].nodes[0].mapping #the CurveMapping
myCurveMapping.initialize() #it needs to be initialized
curve = myCurveMapping.curves[3] #the Composite-Curve of the RGB Curves
print(bpy.data.node_groups[‘myCurve’].nodes[0].mapping.evaluate(curve, 0.5)) #prints value

1 Like