Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

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
    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?
    1. max group group
    2. (
    3. ResetPivot $
    4. CenterPivot $
    5. for i in selection do (
    6. i.pivot = [0, 0, 0]
    7. )
    8. )
    9. max tti
    10. if queryBox "Do you want to ungroup?" beep:false then (
    11. max group ungroup
    12. )
    13. 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
    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
    Offline / Send Message
    LoTekK polycounter lvl 19
    Dialogs and rollouts are your friends :p
    1. (
    2. local objs
    3. local spinnerRange = 1000 --
    4. local spinnerScale = 0.5 --adjust as appropriate
    5.  
    6. rollout repositionRollout "Reposition" (
    7. spinner posX "Position X" range: [-spinnerRange, spinnerRange, 0] scale: spinnerScale
    8. spinner posY "Position Y" range: [-spinnerRange, spinnerRange, 0] scale: spinnerScale
    9. spinner posZ "Position Z" range: [-spinnerRange, spinnerRange, 0] scale: spinnerScale
    10. button applyTransform "Apply" width: 100
    11. on repositionRollout open do (
    12. objs = group $*
    13. centerPivot objs
    14. for o in objs do (
    15. o.pivot = [0,0,0]
    16. )
    17. )
    18. on posX changed n do (
    19. objs.position.x = n
    20. )
    21. on posY changed n do (
    22. objs.position.y = n
    23. )
    24. on posZ changed n do (
    25. objs.position.z = n
    26. )
    27. on applyTransform pressed do (
    28. ungroup objs
    29. for o in $* do (
    30. resetPivot o
    31. )
    32. destroyDialog repositionRollout
    33. )
    34. )
    35. createDialog repositionRollout-- modal: true
    36. )

    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
    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
    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.