저는 블렌더에서 파이썬을 가르치기 때문에 스크립트를 사용하여 간단한 연산자를 만들려고했습니다. 스크립트는 아래에 있습니다 - 의도는 현장에서 네 개의 (스폿) 램프를 선택하고 에너지를 변경하는 것입니다 (기본적으로 조명을 켜고 끕니다). 그러나 스크립트를 실행하려고하면 "Python 스크립트 실패"라는 오류 메시지가 나타납니다. 코드에 어떤 문제가 있는지 누구나 볼 수 있습니까?블렌더 : 파이썬 스크립트가 실패했습니다 (간단한 연산자 생성)
import bpy
def main(context):
for ob in context.scene.objects:
print(ob)
class LightsOperator(bpy.types.Operator):
bl_idname = "object.lights_operator"
bl_label = "Headlight Operator"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
light1 = bpy.data.objects['headlight1']
light2 = bpy.data.objects['headlight2']
light3 = bpy.data.objects['headlight3']
light4 = bpy.data.objects['headlight4']
if light1.energy==0.0:
light1.energy = 0.8
else:
light1.energy = 0.0
if light2.energy==0.0:
light2.energy = 0.8
else:
light2.energy = 0.0
if light3.energy==0.0:
light3.energy = 0.8
else:
light3.energy = 0.0
if light4.energy==0.0:
light4.energy = 0.8
else:
light4.energy = 0.0
return {'FINISHED'}
def register():
bpy.utils.register_class(LightsOperator)
def unregister():
bpy.utils.unregister_class(LightsOperator)
if __name__ == "__main__":
register()
# test call
bpy.ops.object.lights_operator()
실제 들여 쓰기가 맞습니까? – jonrsharpe
블렌더에 관한 질문을 게시하려면 [이 전용 StackExchange 사이트] (http://blender.stackexchange.com/) –
블렌더 전문 파이썬 밖에서 파이썬을 배우는 것이 좋습니다 ... 블렌더 파이썬이 사용하기 쉽습니다 unpythonic 또는 반 직관적 인 것으로 간주되는 몇 가지 사항. –