--- Operating System, Graphics card ---
w7 - 64
--- Blender version with error, and version that worked ---
2.68a release w64, no other version works but behavior changes:
- blender-2.68-r59724M-win64 and r54389 all give identical behavior (hard crash, nothing on console)
- 2.64a release, hangs before crashing (but still w.o. anything on the console)
- 2.63 throws exception 'CurveMap has no attribute evaluate'
--- Short description of error ---
Accessing an apparently uninitialized brush curvemap causes a hard crash instead of an exception
--- Steps for others to reproduce the error (preferably based on attached .blend file) ---
crash scenario:
- open attached .blend
- click 'run script' in text editor
- crash
non-crash scenario:
- open attached .blend
- switch to vertex paint mode
- switch back to object mode
- click 'run script' in text editor
- a value is printed on the console
Description
Event Timeline
I attempted a fix for this, in 59965 it solves the crash but not entirely sure it will always return the correct values if curvemapping_initialize is not called first.
Antony, python could work like C, add an initialize() call that RNA can access, and evaluate() can report an error if the table is not initialized, (I think this is the most straightforward way to resolve).
would love to test the result (because I have a second suspicious scenario which isn't as easy to convert to a one liner :-) but buildbot hasn't produced a w64 version yet with this patch. As soon as that turns up I'll test it. Thanks for the effort anyway.
I have changed the behaviour to match our c code conventions. CurveMapping owner of CurveMap must be initialized first before calling evaluate(). So the correct python code from r60055 and on will be:
"""
import bpy
cm = bpy.context.tool_settings.vertex_paint.brush.curve
cm.initialize()
c = cm.curves[0]
v = c.evaluate(0.5)
print(v)
"""
Fixed the behaviour so it won't crash now but it prints an error instead if the curve is uninitialized. Thanks for reporting and thanks Campbel for the help!