Home Technical Talk

Max script, how to pause then move

codyaq2
greentooth
Offline / Send Message
codyaq2 greentooth
Hey all :)

So currently I have this;
max select all
max group group
(
ResetPivot $
CenterPivot $
for i in selection do
(
i.pivot = [0, 0, 0]
)
)
max tti
max group ungroup

I want to select all, group, move the pivot to 0,0,0, then be able to move the group to a new area, then ungroup the objects.
Question is, how do i pause the script when the move transform type in box comes up, so i can enter a new values, then continue the script once i close the box????

Replies

  • Mark Dygert
    Options
    Offline / Send Message
    I don't think there is a way to wait until the TTI is closed then carry on. I don't think its exposed in maxscript. What I guess you could do, is use a querrybox that would trigger the rest of the script when you clicked yes?
    max group group
    (
        ResetPivot $
        CenterPivot $
        for i in selection do    (
            i.pivot = [0, 0, 0]
        )
    )
    max tti
    if queryBox "Do you want to ungroup?" beep:false then (
        max group ungroup 
    )
    else ()
    

    Alternatively I guess you could come up with your own UI that mimics the TTI but triggers the rest of the script when values are changed or a button is pressed.
  • codyaq2
    Options
    Offline / Send Message
    codyaq2 greentooth
    Hey man, thanks for the reply :)
    Unfortunately i have tried that already before, and the issue why i didn't continue to use that is because the querybox locks out max, so you have to press yes or no before you can edit the TTI :(
  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    Dialogs and rollouts are your friends :p
    (
    	local objs
    	local spinnerRange = 1000	--
    	local spinnerScale = 0.5	--adjust as appropriate
    
    	rollout repositionRollout "Reposition" (
    		spinner posX "Position X" range: [-spinnerRange, spinnerRange, 0] scale: spinnerScale
    		spinner posY "Position Y" range: [-spinnerRange, spinnerRange, 0] scale: spinnerScale
    		spinner posZ "Position Z" range: [-spinnerRange, spinnerRange, 0] scale: spinnerScale
    		button applyTransform "Apply" width: 100
    		on repositionRollout open do (
    			objs = group $*
    			centerPivot objs
    			for o in objs do (
    				o.pivot = [0,0,0]
    			)
    		)
    		on posX changed n do (
    			objs.position.x = n
    		)
    		on posY changed n do (
    			objs.position.y = n
    		)
    		on posZ changed n do (
    			objs.position.z = n
    		)
    		on applyTransform pressed do (
    			ungroup objs
    			for o in $* do (
    				resetPivot o
    			)
    			destroyDialog repositionRollout
    		)
    	)
    	
    	createDialog repositionRollout-- modal: true
    )
    

    edit:
    the script should probably record the original pivots of each object so it can restore them if necessary. For now the script above just does a resetPivot for each object after ungrouping.
  • Mark Dygert
    Options
    Offline / Send Message
    codyaq2 wrote: »
    Hey man, thanks for the reply :)
    Unfortunately i have tried that already before, and the issue why i didn't continue to use that is because the querybox locks out max, so you have to press yes or no before you can edit the TTI :(
    Oh right, in that case I guess you would use a standard rollout with a button that acts like a querybox but won't lock up max, it will just pop up.


    LotekK seems to be onto something too. I would probably roll with that =)
  • codyaq2
    Options
    Offline / Send Message
    codyaq2 greentooth
    Cheers heaps for the replies :)

    So i just went with this.....
    rollout mover_script "Input Move" width:159 height:62
    (
    button btn1 "Group" pos:[9,7] width:66 height:19
    button btn2 "Move" pos:[9,30] width:66 height:19
    button btn3 "Ungroup" pos:[100,9] width:66 height:19
    on btn1 pressed do
    (
    select $*
    max group group
    $Group001.pivot = [0,0,0]
    )
    on btn2 pressed do
    (
    max tti
    messagebox "Remember to copy and paste these values down"
    )
    on btn3 pressed do
    (
    max select all
    max group ungroup
    )
    )
    floater= newrolloutfloater "xxx" 200 100
    addrollout mover_script floater

    $Group001.pivot = [0,0,0] only moves the group pos, not the objects inside, so thats what i wanted.


    I may implement yours though LoTekK :):)
Sign In or Register to comment.