hey again i cant figure out how to pass the floatFieldGrp to my class. So that i can alter a certain % of an object instead of an exact copy.
CODE
import maya.cmds as mc
import sys
import string
class ButtonTest:
def __init__(self,name,name2,perc1,perc2):
self.firstObj = name
self.secondObj = name2
self.percentage1 = perc1
self.percentage2 = perc2
print self.percentage1
def firstButton(self,*args):
obj1 = mc.ls(sl=True)
self.firstObj = obj1
def secondButton(self,*args):
obj2 = mc.ls(sl=True)
self.secondObj = obj2
def percentage(self,*args):
percentage1 = mc.floatFieldGrp(percentage, query=True,v1=True) #dont understand how to query.
def compute(self,*args):
if (string.find(self.firstObj[0],'.vtx')>1 and string.find(self.secondObj[0],'.vtx') > 1 ):
point=mc.filterExpand(self.firstObj,sm=31)
point2=mc.filterExpand(self.secondObj,sm=31)
for i in point2:
findVtx2 = string.find(i,".")
shape2 = i[:findVtx2]
for i in range(len(point)):
pp=mc.pointPosition(point[i],local=True)
findVtx = string.find(point[i],".")
selectedVtx = point[i][findVtx:]
change = shape2+selectedVtx
mc.xform(change, ws=True, t=(pp[0],pp[1],pp[2]))
elif(string.find(self.firstObj[0],'.cv')>1 and string.find(self.secondObj[0],'.cv') > 1 ):
point=mc.filterExpand(self.firstObj,sm=28)
point2=mc.filterExpand(self.secondObj,sm=28)
for i in point2:
findVtx2 = string.find(i,".")
shape2 = i[:findVtx2]
for i in range(len(point)):
pp=mc.pointPosition(point[i],local=True)
findVtx = string.find(point[i],".")
selectedVtx = point[i][findVtx:]
change = shape2+selectedVtx
mc.xform(change, ws=True, t=(pp[0],pp[1],pp[2]))
elif(string.find(self.firstObj[0],'.smp')>1 and string.find(self.secondObj[0],'.smp') > 1 ):
point=mc.filterExpand(self.firstObj,sm=36)
point2=mc.filterExpand(self.secondObj,sm=36)
for i in point2:
findVtx2 = string.find(i,".")
shape2 = i[:findVtx2]
for i in range(len(point)):
pp=mc.pointPosition(point[i],local=True)
findVtx = string.find(point[i],".")
selectedVtx = point[i][findVtx:]
change = shape2+selectedVtx
mc.xform(change, ws=True, t=(pp[0],pp[1],pp[2])) #would like to bring the percantage here so that it changes the object by a certain percent instead of exact copy
else:
print "not right kind of objects"
def myMain():
test = ButtonTest(None,None,None,None)
myWindow ='selecting'
if mc.window(myWindow, exists = 1):
mc.deleteUI(myWindow)
window = mc.window( myWindow, title = "shape", iconName='Sl', widthHeight=(200, 55),rtf=True )
mc.columnLayout()
mc.text(label="please select component vtx or cvs only.")
mc.button(label='select original object',command =test.firstButton)
mc.button(label='changing object',command =test.secondButton)
percentage = mc.floatFieldGrp(label='percentage',numberOfFields=3, value1=2, value2=5, value3=1)
percentage2 = mc.floatFieldGrp(percentage, query=True,v2=True) #how can i send these to the class button test
percentage3 = mc.floatFieldGrp(percentage, query=True,v3=True) #how can i send these to the class button test
mc.button(label='Percentage',command =test.percentage)
mc.button(label='compute',command =test.compute)
mc.showWindow(myWindow)
myMain()