繁体   English   中英

Blender + Python

[英]Blender + Python

import bpy 
    positions = (0,3,2) , (4,1,6) , (3,-5,1) , (3,10,1) , (1,8,1)
    start_pos =(0,0,0)
    ob = bpy.data.objects ["Sphere"]
    frame_num = 0 
     for position in positions:
         bpy.context.scene.frame_set(frame_num)
         ob.location = position
         ob.keyframe_insert(data_path="location", index =-1)
         frame_num +=20

谁能帮助我认识到错误以及代码的哪一部分是错误的,我无法理解什么是错误的

这是错误“ Python脚本失败,请在系统控制台中检查消息”

python脚本中使用的格式会影响其解释方式。 您需要确保每个代码块都有匹配的缩进,通常每个缩进设置四个空格。

有一个关于如何格式化python脚本的正式规范,通常称为PEP 8

脚本的正确格式应为:

import bpy 
positions = (0,3,2) , (4,1,6) , (3,-5,1) , (3,10,1) , (1,8,1)
start_pos =(0,0,0)
ob = bpy.data.objects ["Sphere"]
frame_num = 0 
for position in positions:
    bpy.context.scene.frame_set(frame_num)
    ob.location = position
    ob.keyframe_insert(data_path="location", index =-1)
    frame_num +=20

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM