i9089303
11-17-2010, 01:47 PM
hello
I have write a python script for maya which creates suction cups for octopus which work as I wanted it. When the script run, there is a window with few sliders which controls the length and the width of the of the cup. The tool is basically a series of 3 extrude. The slider have access to to each one of these (as long the history is not deleted) using setAttr command.
I want to be able run the script as many times as I need it, creating deferent shapes, without deleting the previous windows which is easy but when I am running the script and a new windows opens the old on does not have access to its own cup(s). Actually when I am trying to move the sliders, they pass the values of the new window. I guess this has something to do with the variables. How can I do it so that each windows (as long is open) be able to control the cups that it has create.
Maybe I am not giving the best explanation so I am gonna write down the script and you can run it in order to review the problem.
Thanks.
value = 0.5
extrFirst = cmds.polyExtrudeFacet( kft=False, ltz=value, ls=(1, 1, 0) )
extrOutRing = cmds.polyExtrudeFacet( ls=(.3, .3, 0) )
extrSecond = cmds.polyExtrudeFacet( ltz=-(value/2))
cmds.window( t='Suction Cup Generator', s=False)
cmds.columnLayout()
cmds.floatSliderGrp( 'length', l='Length', cw3=(50,1,200), f=True,
min=0.01, max=1.0, fmn=0.01, fmx=100.0, v=0.5, s=0.01, dc='changeLength()')
cmds.floatSliderGrp( 'widthOut', l='Width out', cw3=(50,1,200), f=True,
min=0, max=10, fmn=0, fmx=100.0, v=1, s=0.01, dc='changeWidthOut()')
max = cmds.floatSliderGrp( 'widthOut', q=True, v=True )
cmds.floatSliderGrp( 'widthIn', l='Width in', cw3=(50,1,200), f=True,
min=0, max=max, fmn=0, fmx=max, v=0.3, s=0.01, dc='changeWidthIn()')
cmds.showWindow()
def changeLength():
length = cmds.floatSliderGrp( 'length', q=True, v=True )
cmds.setAttr( '%s.localTranslateZ' % extrFirst[0], length )
cmds.setAttr( '%s.localTranslateZ' % extrSecond[0], -(length/2) )
def changeWidthIn():
widthIn = cmds.floatSliderGrp( 'widthIn', q=True, v=True )
cmds.setAttr( '%s.localScaleX' % extrOutRing[0], widthIn )
cmds.setAttr( '%s.localScaleY' % extrOutRing[0], widthIn )
def changeWidthOut():
widthOut = cmds.floatSliderGrp( 'widthOut', q=True, v=True )
cmds.setAttr( '%s.localScaleX' % extrFirst[0], widthOut )
cmds.setAttr( '%s.localScaleY' % extrFirst[0], widthOut )
I have write a python script for maya which creates suction cups for octopus which work as I wanted it. When the script run, there is a window with few sliders which controls the length and the width of the of the cup. The tool is basically a series of 3 extrude. The slider have access to to each one of these (as long the history is not deleted) using setAttr command.
I want to be able run the script as many times as I need it, creating deferent shapes, without deleting the previous windows which is easy but when I am running the script and a new windows opens the old on does not have access to its own cup(s). Actually when I am trying to move the sliders, they pass the values of the new window. I guess this has something to do with the variables. How can I do it so that each windows (as long is open) be able to control the cups that it has create.
Maybe I am not giving the best explanation so I am gonna write down the script and you can run it in order to review the problem.
Thanks.
value = 0.5
extrFirst = cmds.polyExtrudeFacet( kft=False, ltz=value, ls=(1, 1, 0) )
extrOutRing = cmds.polyExtrudeFacet( ls=(.3, .3, 0) )
extrSecond = cmds.polyExtrudeFacet( ltz=-(value/2))
cmds.window( t='Suction Cup Generator', s=False)
cmds.columnLayout()
cmds.floatSliderGrp( 'length', l='Length', cw3=(50,1,200), f=True,
min=0.01, max=1.0, fmn=0.01, fmx=100.0, v=0.5, s=0.01, dc='changeLength()')
cmds.floatSliderGrp( 'widthOut', l='Width out', cw3=(50,1,200), f=True,
min=0, max=10, fmn=0, fmx=100.0, v=1, s=0.01, dc='changeWidthOut()')
max = cmds.floatSliderGrp( 'widthOut', q=True, v=True )
cmds.floatSliderGrp( 'widthIn', l='Width in', cw3=(50,1,200), f=True,
min=0, max=max, fmn=0, fmx=max, v=0.3, s=0.01, dc='changeWidthIn()')
cmds.showWindow()
def changeLength():
length = cmds.floatSliderGrp( 'length', q=True, v=True )
cmds.setAttr( '%s.localTranslateZ' % extrFirst[0], length )
cmds.setAttr( '%s.localTranslateZ' % extrSecond[0], -(length/2) )
def changeWidthIn():
widthIn = cmds.floatSliderGrp( 'widthIn', q=True, v=True )
cmds.setAttr( '%s.localScaleX' % extrOutRing[0], widthIn )
cmds.setAttr( '%s.localScaleY' % extrOutRing[0], widthIn )
def changeWidthOut():
widthOut = cmds.floatSliderGrp( 'widthOut', q=True, v=True )
cmds.setAttr( '%s.localScaleX' % extrFirst[0], widthOut )
cmds.setAttr( '%s.localScaleY' % extrFirst[0], widthOut )
