2016-04-03 48 views
-2

我已经仔细检查了这一点。每条线似乎都有道理。我抓着我的头,我整个下午都在这里。你能帮忙弄清楚发生了什么事吗?非关键字Arg关键字Arg后Python

感谢提前:)

# 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. 
+1

这将是有益的知道 –

回答

1

粉饰你的代码看起来有问题的行如下:

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

当发送参数关键字参数预计将有参数不是由关键字指定的。所以你在(0,0)之后设置location=...

而且,看着*args and **kwargs? 可能是有用的:

+0

由于发生错误哪一行!我不知道你是否能够再次提供帮助? :)我尝试了其他的东西,它仍然无法正常工作。 (location =(0,0,(i +(i * 0.5)))) - 我没有得到arg后的非关键字,但它仍然不会运行。这次没有提供任何具体的错误 – aerotortoise

+0

您是否尝试复制粘贴在答案中的行?它看起来像你用'(0,0)'合并了'location =(i +(i * 0.5))'这可能会抛出一个错误,因为你现在已经使该参数成为它可能不期望的值的元组 – Pythonista

+0

修复了线!谢谢一堆! :d – aerotortoise

相关问题