Hi Isai,

Sounds like a tricky situation, as when would the code know the user is 
done "tweaking" the slider and happy with the result, as you are 
continuesly apply the command. if you store the original state before a 
tweak, you will end up with a ton of undos, which is the situation you are 
in now.

You could store the original position of the selected object when the ui is 
loaded, that way if the user performs an undo, it goes back to the start 
position. That is half way there, as you wil have problems if users select 
another object while the ui is open. So you would have to put a check, to 
see if you are already storing that objects position in an undo dictionary 
(im rambling a bit)

You could try implement a timer, that is the user doesn't slide the bar for 
a few seconds then it stores overwrites the undo transform that is being 
stored

as you are using commands, each command store an undo in Mayas stack, I 
would suggest you start using OM1 or OM2, preferably OM2 to perform these 
moves, as that way you get to control the undo stack that Maya registers.

How do you see users interacting with the UI?

On Thursday, 19 October 2017 12:46:12 UTC+11, Isai Calderon wrote:
>
> I have a window with an interactive slider moving keys around (keying is 
> unnecessary). Unfortunately the Undo queue loads up with every tiny change 
> in value.
>
> The idea is to move the slider many times until it's just right, sometimes 
> even closing the UI and opening it up again, all while not loading the Undo 
> queue.
>
> Any ideas on how to group all the instances of the "moveJimmy" command 
> below that the slider activates into a single Undo function?
>
> The script is for moving keys, but the following code is a good example of 
> what's going on. Makes sphere, makes UI with slider, slider moves sphere up 
> and down:
>
> import maya.cmds as mc
>
> class Jimmy(object):
>     
>     def __init__(self):
>         ''' Make Jimmy '''
>         mc.polySphere(name='Jimmy')
>
>     def makeJimmyUI(self,*args,**kwargs):
>         ''' Make Jimmy's window '''
>         
>         # Remove UI if it already exists
>         if mc.window('jimmyUI',query=1,exists=1):
>             mc.deleteUI('jimmyUI')
>         
>         mc.window('jimmyUI')
>         mc.columnLayout()
>
>         # Create Jimmy's slider
>         mc.floatSliderGrp('allInTheHips',
>                           label='Move Jimmy',
>                           dragCommand=self.moveJimmy, # Have Jimmy's 
> slider activate moveSphere
>                           sliderStep=0.1,
>                           minValue=-10,
>                           maxValue=10,
>                           )
>
>         # Show Jimmy's Window
>         mc.showWindow('jimmyUI')
>     
>     def moveJimmy(self,*args, **kwargs):
>         ''' Move Jimmy up and down '''
>         print 'yup'
>         # value = value
>         mc.setAttr('Jimmy.translateY',
>                    mc.floatSliderGrp('allInTheHips',
>                                      query=True,
>                                      value=True)
>                    )
>
>
> James = Jimmy()
> James.makeJimmyUI() # As long as "Jimmy" exists, this UI can be reopened 
> later
>
>
> Thank you!!
>
> All the best,
>
> Isai
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/05b67b23-922a-48ae-90e1-c24a540d1dee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to