-2

I have double checked this. Every line seems to make sense. I'm scratching my head, i've been at this all afternoon. Can you help figure out what's going on?

Thanks in advance :)

# Program to create 64 cubes for an animation suite, named blender.

import bpy
#make 64 of the following thing.

for i in range (0,64):

   # Step 1 - make a plane, move along a bit ready for the next one.

    # Make a plane.
    bpy.ops.mesh.primitive_plane_add(location = (i+(i*0.5)),(0,0))
    # Move the cursor to the active object.
    bpy.context.scene.cursor_location = bpy.context.active_object.location
    # Move the cursor along y, minus 1 space. 
    bpy.context.scene.cursor_location.y -= 1
    # Set the object origin to the cursor. (What?)
    bpy.ops.object.origin_set(type='ORIGIN_CURSOR')

   # Step 2 - Size the plane how you want.

    # Scale the new plane you made.
    bpy.context.active_object.scale.x = 0.5
    bpy.context.active_object.scale.y = 20
    # Do a transformation, only use scale.
    bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)

   # Step 3 - Add 2 keyframes for an F curve. (Function Curve)

    #
    bpy.ops.anim.keyframe_insert_menu(type='Scaling')
    #initialise 2 types of scaling. 0 is x, 2 is z(?) 1 is y. y is used at the end.
    bpy.context.active_object.animation_data.action.fcurves[0].lock = True
    bpy.context.active_object.animation_data.action.fcurves[2].lock = True

    #Opens Graph Editor
    bpy.context.area.type = 'GRAPH_EDITOR'



    #sets how the block reacts by giving numbers to those keyframes.

    #l or LOW is the highest frequency the block reacts to.
    l = i**2 + 20

    #h or HIGH is the highest frequency a block reacts to.
    #add one to 1, incrementing it
    h = (i+1)**2 + 20

    #puts strings into the console.
    print (str(i) + str(l) + str(h))

    #Render. or "Bake" as we are calling it here. Feed the song into the oven, too! nom.
    #Also, set the low and high settings of the sound bake program to l and h.

    bpy.ops.graph.sound_bake(filepath=r'~/PlayMax/Blender/sawwipe.mp3', low = (l), high = (h))

    # Initialise the y axis [1]
    bpy.context.active_object.animation_data.action.fcurves[1].lock = True

    # That's it! All ready to repeat 63 more times.
chepner
  • 497,756
  • 71
  • 530
  • 681

1 Answers1

1

Glossing over your code it looks like the offending line is the following:

bpy.ops.mesh.primitive_plane_add(location = (i+(i*0.5)),(0,0))

When sending arguments keyword argument are expected to come after arguments that aren't specified by a keyword. So you set location=... after (0,0).

Also, looking at *args and **kwargs? might be useful:

Community
  • 1
  • 1
Pythonista
  • 11,377
  • 2
  • 31
  • 50
  • Thanks! I don't know if you would be able to help again? :) I tried something else and it still won't work. (location = (0 , 0 , (i + (i*0.5)) ) ) - I'm not getting the non keyword after arg anymore, but it still won't run. Doesn't give any specific errors this time – andyswebportfolio Apr 03 '16 at 16:43
  • Did you try copying pasting the line in answer? It looks like you merged `location=(i+(i*0.5))` with `(0,0)` which is probably throwing an error because you've now made that parameter a tuple of values it probably isnt expecting – Pythonista Apr 03 '16 at 16:50
  • Fixed the line! Thanks a bunch! :D – andyswebportfolio Apr 03 '16 at 19:25