Reputation: 68
I am working through Maya Programming with Python Cookbook by Adrian Herbez and having trouble with an example (pg. 31) which creates a class which produces a user interface for making simple spheres in Maya. When I reproduce the code and run the script it loads but nothing happens in Maya. I was able to create user interfaces without using the class method previously so I am wondering if there is something wrong with the class code. My understanding of classes is a bit shaky but I can't find what could be wrong with it. I am using Atom and calling the script using
import(makeSpheres)
and reload(makeSpheres)
.
Here is the code:
import maya.cmds as cmds
class SpheresClass:
def __init__(self):
self.win = cmds.window(title="Make Spheres",widthHeight=(300,200))
cmds.columnLayout()
self.numSpheres = cmds.intField(minValue=1)
cmds.button(label="Make some spheres", command=self.makeSpheres)
cmds.showWindow(self.win)
def makeSpheres(self, *args):
number = cmds.intField(self.numSpheres,query=True,value=True)
for i in range(0,number):
cmds.polySphere()
cmds.move(i*2.2,0,0)
SpheresClass()
In Atom the self.win
,self.numSpheres
and self.makeSpheres
is being highlighted in red but but the linter doesn't have any error messages.
Upvotes: 1
Views: 1395
Reputation: 68
Turns out I was calling the SpheresClass
from within the makeSpheres
function.
Upvotes: 1