<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Maya Push/Relax Script in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322494#M11669</link>
    <description>&lt;P&gt;Ah, I see now, even though it's been there all along. My solution made the values update when you moved the slider but you actually want the value to be read out when you hit the Apply button. Now it makes sense. In that case a slightly different modification is in order, which is closer to your original, only changing the call to mel.eval in the slider() function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import maya.cmds as cmds
import maya.mel as mel

if cmds.window("cusWin", exists = True):
    cmds.deleteUI("cusWin")
    
  
customwindow = cmds.window("cusWin",t= "Push/Relax", wh = (200, 117), s= False, mnb= False, mxb= False)
cmds.frameLayout( label='Push/Relax Modifier', borderStyle='in', cll= False)
cmds.columnLayout(adj = True, columnOffset= ("both", 3))


cmds.radioCollection()
push = lambda _: cmds.artPuttyCtx(cmds.currentCtx(), e = True,  mtm='push')
relax = lambda _: cmds.artPuttyCtx(cmds.currentCtx(), e = True, mtm='relax')


cmds.radioButton(l = "Push", onc= push, select = True)
cmds.radioButton(l = "Relax", onc=relax)

cmds.separator(style= "none", h= 3)

cmds.separator(style= "none", h= 3)

DynFsgCol1 = 30
DynFsgCol2 = 50
DynFsgCol3 = 100

valSlider = cmds.floatSliderGrp(l = "Value", field = True, min = 0, max= 5, precision = 4, cw3= (DynFsgCol1, DynFsgCol2, DynFsgCol3 ))
cmds.separator(style= "none", h= 3)

cmds.rowColumnLayout(numberOfColumns=2, columnWidth=[(1,98),(2,100)], columnOffset=[(1,'left',1),(2,'right',95)])
cmds.button(l = "Apply", w= 92, c= 'slider()')
cmds.button(l = "Reset", w= 91, c= 'resetButton()')

cmds.showWindow( customwindow )

# put the defs here, where the names of the slider are known
def slider():
    value = cmds.floatSliderGrp( valSlider, query=True, value=True )
    print 'Changed value to {}'.format(value)
    mel.eval('artPuttyCtx -e -maxdisp ' + str(value) + '`currentCtx`;')

def resetButton(*_):
    cmds.resetTool(cmds.currentCtx())
&lt;/PRE&gt;
&lt;P&gt;By the way, a very useful technique for this kind of UI manipulation is to put all of the methods into a class. That way you can avoid using global variables.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2017 14:57:20 GMT</pubDate>
    <dc:creator>kevin.picott</dc:creator>
    <dc:date>2017-08-23T14:57:20Z</dc:date>
    <item>
      <title>Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7205419#M11662</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi all. I'm trying to make a custom script that replicates/imitates the Maya Sculpt Geometry Tool. Basically I have 2 radio buttons, Push and Relax[which imitates the push and relax from the sculpt parameters obviously], a value slider[replicates the max displacement slider]. The radio and reset button works perfectly however I'm having problems with coding the slider. Any help for this one? Thanks in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 681px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/374553iD2A63FCF4A34395B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Code:&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;import maya.cmds as cmds
import maya.mel as mel


if cmds.window("cusWin", exists = True):
    cmds.deleteUI("cusWin")
        
    

customwindow = cmds.window("cusWin",t= "Push/Relax", wh = (200, 117), s= False, mnb= False, mxb= False)
cmds.frameLayout( label='Push/Relax Modifier', borderStyle='in', cll= False)
cmds.columnLayout(adj = True, columnOffset= ("both", 3))


cmds.radioCollection()
cmds.radioButton(l = "Push", onc= "mel.eval('artUpdatePuttyOperation artPuttyCtx push ;')")
cmds.radioButton(l = "Relax", onc= "mel.eval('artUpdatePuttyOperation artPuttyCtx relax ;')")

cmds.separator(style= "none", h= 3)

DynFsgCol1 = 30
DynFsgCol2 = 50
DynFsgCol3 = 100
 
valSlider = cmds.floatSliderGrp(l = "Value", field = True, min = 0, max= 5, precision = 4, cw3= (DynFsgCol1, DynFsgCol2, DynFsgCol3 ))
cmds.separator(style= "none", h= 3)

cmds.rowColumnLayout(numberOfColumns=2, columnWidth=[(1,98),(2,100)], columnOffset=[(1,'left',1),(2,'right',95)])
cmds.button(l = "Apply", w= 92, c= 'slider()')
cmds.button(l = "Reset", w= 91, c= 'resetButton()')

cmds.showWindow( customwindow )


def slider():
    valueSlider = cmds.floatSliderGrp(valSlider, q= True, value= True)
    mel.eval('artPuttyCtx -e -maxdisp valueSlider `currentCtx`;')
    
def resetButton():
    mel.eval('resetTool artPuttyContext;')
    
    
    
    &lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 12:07:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7205419#M11662</guid>
      <dc:creator>Admiral.Pixel</dc:creator>
      <dc:date>2017-07-05T12:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7321746#M11663</link>
      <description>&lt;P&gt;I assume that you're having trouble getting the value to the Mel command in the slider() function. To do this you need to do two things. First, define a changeCommand argument for the floatSliderGrp command:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;valSlider = cmds.floatSliderGrp(changeCommand=slider, l = "Value", field = True, min = 0, max= 5, precision = 4, cw3= (DynFsgCol1, DynFsgCol2, DynFsgCol3 ))
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, change the slider() function to accept the new value as a parameter, and then construct the Mel string using that new value. (Be sure to define the slider() function before the above call, so that it knows where to find it.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;def slider(value):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Changed value to {}'.format(value)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mel.eval('artPuttyCtx -e -maxdisp ' + str(value) + '`currentCtx`;')&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 12:03:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7321746#M11663</guid>
      <dc:creator>kevin.picott</dc:creator>
      <dc:date>2017-08-23T12:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322216#M11664</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1650167"&gt;@kevin.picott&lt;/a&gt;&amp;nbsp;Hi there sir and thanks for reply. The values from the slider matches the one from the sculpt geometry tool now. Thanks for that. However, when I click the apply button I'm getting an error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;"# Error: TypeError: file &amp;lt;maya console&amp;gt; line 1: slider() takes exactly 1 argument (0 given) # " and obviously this is from the "slider" def. I don't know what to change there and I would be glad if you can help me there. Thanks a lot.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here's my script so far.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;import maya.cmds as cmds
import maya.mel as mel


if cmds.window("cusWin", exists = True):
    cmds.deleteUI("cusWin")



customwindow = cmds.window("cusWin",t= "Push/Relax", wh = (200, 117), s= False, mnb= False, mxb= False)
cmds.frameLayout( label='Push/Relax Modifier', borderStyle='in', cll= False)
cmds.columnLayout(adj = True, columnOffset= ("both", 3))


cmds.radioCollection()
push = lambda _: cmds.artPuttyCtx(cmds.currentCtx(), e = True,  mtm='push')
relax = lambda _: cmds.artPuttyCtx(cmds.currentCtx(), e = True, mtm='relax')


cmds.radioButton(l = "Push", onc= push, select = True)
cmds.radioButton(l = "Relax", onc=relax)

cmds.separator(style= "none", h= 3)

cmds.separator(style= "none", h= 3)

DynFsgCol1 = 30
DynFsgCol2 = 50
DynFsgCol3 = 100

valSlider = cmds.floatSliderGrp(changeCommand=slider, l = "Value", field = True, min = 0, max= 5, precision = 4, cw3= (DynFsgCol1, DynFsgCol2, DynFsgCol3 ))
cmds.separator(style= "none", h= 3)

cmds.rowColumnLayout(numberOfColumns=2, columnWidth=[(1,98),(2,100)], columnOffset=[(1,'left',1),(2,'right',95)])
cmds.button(l = "Apply", w= 92, c= 'slider()')
cmds.button(l = "Reset", w= 91, c= 'resetButton()')

cmds.showWindow( customwindow )


# put the defs here, where the names of the slider are known
    
def slider(value):
    print 'Changed value to {}'.format(value)
    mel.eval('artPuttyCtx -e -maxdisp ' + str(value) + '`currentCtx`;')

def resetButton(*_):
    cmds.resetTool(cmds.currentCtx())&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Aug 2017 13:52:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322216#M11664</guid>
      <dc:creator>Admiral.Pixel</dc:creator>
      <dc:date>2017-08-23T13:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322301#M11665</link>
      <description>&lt;P&gt;Move the definition of slider() up to the top of your script - you're probably just picking up the earlier definition that didn't have the value parameter.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:13:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322301#M11665</guid>
      <dc:creator>kevin.picott</dc:creator>
      <dc:date>2017-08-23T14:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322330#M11666</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1650167"&gt;@kevin.picott&lt;/a&gt;&amp;nbsp;Thanks for the quick response. I moved the def slider at top but still getting the same error.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/393192i5288B385E9E450DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:29:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322330#M11666</guid>
      <dc:creator>Admiral.Pixel</dc:creator>
      <dc:date>2017-08-23T14:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322373#M11667</link>
      <description>&lt;P&gt;That's odd. Does "help(slider)" show the version with a parameter in it?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:31:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322373#M11667</guid>
      <dc:creator>kevin.picott</dc:creator>
      <dc:date>2017-08-23T14:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322436#M11668</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1650167"&gt;@kevin.picott&lt;/a&gt;&amp;nbsp;I think yes sir or no clue. But here's the actual code I made. The script is super basic since I'm still a beginner. I'm trying to replicate the deform modifier in XSI which has a push and relax modifiers. The advantage of it is it relaxes the mesh without changing the volume in which Maya doesn't have at the moment so I'm trying to look for an alternative, hence making the script. Sorry for all the inconveniences&lt;BR /&gt;&lt;BR /&gt;Push/Relax Modifer Script:&amp;nbsp;&lt;A href="https://drive.google.com/open?id=0B5bE2wRtMZWPLXBJNjdTSUc2M2M" target="_blank"&gt;https://drive.google.com/open?id=0B5bE2wRtMZWPLXBJNjdTSUc2M2M&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:44:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322436#M11668</guid>
      <dc:creator>Admiral.Pixel</dc:creator>
      <dc:date>2017-08-23T14:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322494#M11669</link>
      <description>&lt;P&gt;Ah, I see now, even though it's been there all along. My solution made the values update when you moved the slider but you actually want the value to be read out when you hit the Apply button. Now it makes sense. In that case a slightly different modification is in order, which is closer to your original, only changing the call to mel.eval in the slider() function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import maya.cmds as cmds
import maya.mel as mel

if cmds.window("cusWin", exists = True):
    cmds.deleteUI("cusWin")
    
  
customwindow = cmds.window("cusWin",t= "Push/Relax", wh = (200, 117), s= False, mnb= False, mxb= False)
cmds.frameLayout( label='Push/Relax Modifier', borderStyle='in', cll= False)
cmds.columnLayout(adj = True, columnOffset= ("both", 3))


cmds.radioCollection()
push = lambda _: cmds.artPuttyCtx(cmds.currentCtx(), e = True,  mtm='push')
relax = lambda _: cmds.artPuttyCtx(cmds.currentCtx(), e = True, mtm='relax')


cmds.radioButton(l = "Push", onc= push, select = True)
cmds.radioButton(l = "Relax", onc=relax)

cmds.separator(style= "none", h= 3)

cmds.separator(style= "none", h= 3)

DynFsgCol1 = 30
DynFsgCol2 = 50
DynFsgCol3 = 100

valSlider = cmds.floatSliderGrp(l = "Value", field = True, min = 0, max= 5, precision = 4, cw3= (DynFsgCol1, DynFsgCol2, DynFsgCol3 ))
cmds.separator(style= "none", h= 3)

cmds.rowColumnLayout(numberOfColumns=2, columnWidth=[(1,98),(2,100)], columnOffset=[(1,'left',1),(2,'right',95)])
cmds.button(l = "Apply", w= 92, c= 'slider()')
cmds.button(l = "Reset", w= 91, c= 'resetButton()')

cmds.showWindow( customwindow )

# put the defs here, where the names of the slider are known
def slider():
    value = cmds.floatSliderGrp( valSlider, query=True, value=True )
    print 'Changed value to {}'.format(value)
    mel.eval('artPuttyCtx -e -maxdisp ' + str(value) + '`currentCtx`;')

def resetButton(*_):
    cmds.resetTool(cmds.currentCtx())
&lt;/PRE&gt;
&lt;P&gt;By the way, a very useful technique for this kind of UI manipulation is to put all of the methods into a class. That way you can avoid using global variables.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 14:57:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322494#M11669</guid>
      <dc:creator>kevin.picott</dc:creator>
      <dc:date>2017-08-23T14:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322550#M11670</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1650167"&gt;@kevin.picott&lt;/a&gt;&amp;nbsp;Excactly sir. I do hope that Maya will have those features in the future like in XSI. They're really useful for topology's equal distribution without affecting the mesh volume. Furthermore, the Apply button is actually for/like the "Flood" in the Sculpt parameters which I'm aiming for. Thank you for all the support and time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/393229i752E63016A516F6B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 15:10:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7322550#M11670</guid>
      <dc:creator>Admiral.Pixel</dc:creator>
      <dc:date>2017-08-23T15:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7323328#M11671</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the problem solved?&lt;/P&gt;
&lt;P&gt;Please mark every answer that solves your problem as solution, so others interested in this thread will get a better overview.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 19:08:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7323328#M11671</guid>
      <dc:creator>mspeer</dc:creator>
      <dc:date>2017-08-23T19:08:52Z</dc:date>
    </item>
    <item>
      <title>Re: Maya Push/Relax Script</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7329068#M11672</link>
      <description>&lt;P&gt;Hi there! It's partially but I'll accept the last replies as a solution.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 14:31:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/maya-push-relax-script/m-p/7329068#M11672</guid>
      <dc:creator>Admiral.Pixel</dc:creator>
      <dc:date>2017-08-25T14:31:59Z</dc:date>
    </item>
  </channel>
</rss>

