2016-04-08 71 views
1

我達到了它使得一個球體的點,然後我得到該錯誤。我不知道該怎麼做。此代碼的整點是使滑塊工作TypeError:'模塊'對象無法調用#

import maya.cmds as cmds 
from functools import partial 
import os 
import random as rand 

class gridTestUI(): 
    def __init__(self, winName="gridTest"): 
     #Attributes of the class 
     self.winTitle = "create a window with a grid layout" 
     #This is the name of the window 
     self.winName = winName 
     self.numSpheres = 3 
     self.getSpheres = [] 
     self.makeSpheres() 
     self.createUI() 
     self.movePlacement = []#my change 
    def createUI(self): 
     #Test to see if the window exists 
     if cmds.window(self.winName, exists=True): 
      #delete the window 
      cmds.deleteUI(self.winName) 
     #create a new window 
     cmds.window(self.winName, title=self.winTitle) 

     cmds.scrollLayout('scrollLayout') 
     cmds.columnLayout(adjustableColumn=True) 
     cmds.frameLayout(label='Buttons', borderStyle='in') 
     self.mainGrid = cmds.gridLayout(numberOfColumns=self.numSpheres, cellWidthHeight=(200, 200))   
     for sphereName in self.getSpheres: 
      cmds.button(l=sphereName,command=partial(self.selectSphere, sphereName)) 
     #This command allow you to create a button 
     cmds.setParent('..') 
     cmds.setParent('..') 
     cmds.frameLayout(label='Sliders', borderStyle='etchedIn') 
     cmds.columnLayout() 
     self.moveSlider = cmds.floatSliderGrp(label='Move Sphere', field=True, minValue=-10.0, maxValue=10.0, value=0) 
     cmds.setParent('..') 
     cmds.setParent('..') 
     cmds.showWindow(self.winName) 
     #cmds.window(self.winName, edit=True, widthHeight=[450,300]) 


    def selectSphere(self,args=None,arg=None): 
     cmds.select(args) 

    def makeSpheres(self): 
      for j in range(self.numSpheres): 
       self.movePlacement = [0,2,3,6,8,10,12,14,16] 
       self.getSpheres.append(cmds.polySphere()[0] 
       cmds.move(movePlacement[j],rand(0,9)*moveSlider,movePlacement[j]) 
    myGrid = gridTestUI() 

我認爲錯誤在這裏出現。 Maya似乎完成了其他代碼。仔細

+1

我們展示了完整的錯誤味精 –

+1

#錯誤:「模塊」對象不是可調用 #回溯(最近通話最後一個): #文件「<瑪雅控制檯>」 60行,在 #文件「< maya console>「,第19行,在__init__中 #文件」「,第57行,在makeSpheres #TypeError:'模塊'對象不可調用# –

+0

對不起我在這裏新建 –

回答

0

查看錯誤消息您發佈的評論:

# Error: 'module' object is not callable 
# Traceback (most recent call last): 
# File "<maya console>", line 60, in <module> 
# File "<maya console>", line 19, in init 
# File "<maya console>", line 57, in makeSpheres 
# TypeError: 'module' object is not callable 

的錯誤是在makeSpheres,所以看這個方法:

def makeSpheres(self): 
    for j in range(self.numSpheres): 
     self.movePlacement = [0,2,3,6,8,10,12,14,16] 
     self.getSpheres.append(cmds.polySphere()[0] 
     cmds.move(movePlacement[j], rand(0, 9) * moveSlider, movePlacement[j]) 

在那裏,它是:rand(0, 9)rand是如何導入random模塊的,如錯誤消息所述,該模塊不可調用。您想調用的是random模塊的randint方法。

更改方法:

def makeSpheres(self): 
    for j in range(self.numSpheres): 
     self.movePlacement = [0,2,3,6,8,10,12,14,16] 
     self.getSpheres.append(cmds.polySphere()[0] 
     cmds.move(
      movePlacement[j], 
      rand.randint(0, 9) * moveSlider, 
      movePlacement[j]) 

,事情應該工作(或者你應該得到一個不同的錯誤,如果有一個不同的問題與您的代碼)。

相關問題