2017-04-10 12 views
-3

に定義されていない私は、元のコードが名前は「...」

from PySide import QtCore 

    i = 0 
    def update(); 
    global i 
App.getDocument("Unnamed2").Pad001.Placement=App.Placement(App.Vector(0,127.5,0), App.Rotation(App.Vector(0,0,1),-i), App.Vector(0,0,0)) 
App.getDocument("Unnamed2").Pad.Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1),i*(74.0/28.0)), App.Vector(0,0,0)) 
i += 0.01 

    timer = QtCore.QTimer() 
    timer.timeout.connect(update) 
    timer.start(1) 

です。これは、ギアアニメーション用のコードですが、それは動作しません

Traceback (most recent call last): 
File "<input>", line 1, in <module> 
NameError: name 'update' is not defined 

を言っメッセージが表示されます。私はコーディングでそれほど良くはないので、私は本当に何が問題なのか分からない。誰でも私を助けることができればいいと思う。ありがとうございました。 :)

+1

は '置き換える;' 'によって:' defは更新 'の後に()' ^^ – Arount

+1

そして、あなたのインデントを修正してください。 –

+0

あなたのタイトルは非常に誤解を招くものです。あなたのパッケージが十分深くネストされているならば、 '...'はimportステートメントで実際に使用できます。それを修正してください。 –

答えて

0

まず、def update();の代わりにdef update():を使用してください。 第二に、あなたが不足しているインデント

from PySide import QtCore 

i = 0 
def update(): 
    global i 
    App.getDocument("Unnamed2").Pad001.Placement=App.Placement(App.Vector(0,127.5,0), App.Rotation(App.Vector(0,0,1),-i), App.Vector(0,0,0)) 
    App.getDocument("Unnamed2").Pad.Placement=App.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(0,0,1),i*(74.0/28.0)), App.Vector(0,0,0)) 
    i += 0.01 

timer = QtCore.QTimer() 
timer.timeout.connect(update) 
timer.start(1)