It is probably (definitely) easier to do this via the Graph Editor but please bear in mind that I am starting out learning Python in Blender so it could end up being just a valuable learning experience rather than a better way of doing things.
I am trying to write a script that will create a cube and add a built in modifier - the default in the Graph Editor is a sine curve. The code below does that. However, I would like to change the Amplitude, Phase Multiplier, Phase Offset and Value Offset. And maybe even the curve type to something else - it would be good to know how.
Standard approach so far has been to copy code from the Info window and try in the Console. When I alter Amplitude in the Graph Editor, for example, the code generated is:
bpy.data.actions[“CubeAction.008”].(null) = 10
This throws up a syntax error because .(null) is invalid when used in Console. Looking at the available options (by pressing TAB after “].” hasn’t helped.
Incidentally, it doesn’t matter what property I change in the Graph Editor, the .(null) thing pops up for all of them in the Info window which is very odd.
I’ve tried using several options. I’ve tried putting that line after the ui_type change in the Text Editor just incase it was down to a context error but that did not work.
After two hours and several cups of tea I’ve come to you chaps for help
#Creates cube, adds keyframe, changes ui.type to add built in sine curve in graph editor
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, align=‘WORLD’, location=(0, 0, 0), scale=(1, 1, 1))
mycube = bpy.data.objects
mycube.keyframe_insert(data_path = “location”, frame = 1)
bpy.context.area.ui_type = ‘FCURVES’
bpy.context.area.ui_type = ‘TEXT_EDITOR’
I have been messing with the following line from sozap who helped with an answer to an earlier question. But I’m not making progress not matter how I modify it