Notifications
Clear all

[Closed] move pivot – reset xform

hi, i’m a total n00b in maxscripting – started it today
so basically what i need is a script that does this:
move pivot point of an object to 0, 0, 0 and then resetXform – and that’s it!

i’ve managed to make a script that moves a pivot and another script that resets x form, but cant pull them together
please help!!!

9 Replies

you can do it for your selection

for o in $selection do
(

o.pivot = [0,0,0]
ResetXform(o)

)

post both, please

this one resets the xform

macroScript ResetXForm category:“reseting”
(

on isEnabled return selection.count > 0
on execute do resetXForm selection
)

and this one resets pivot to zero

[color=Silver]

macroScript ResetPivot category: “reseting”
(
$.pivot = [0,0,0]
)

[/color]

 
macroScript ResetXForm category:"reseting" 
(
	 on isEnabled return selection.count > 0
	 on execute do 
	 (
		 $.pivot = [0,0,0]
		 resetXForm selection
	 )
)
 

wow! thanks a million! it actually worked

actually this one works better, just in case if you have multiple objects selected and you want to reset their pivots. if you don’t have collapseStack at the end it leaves xforms uncollapsed obviously

macroScript ResetXPivot category:“reseting”
(
on isEnabled return selection.count > 0
on execute do
(
$.pivot = [0,0,0]
resetXForm selection
collapseStack selection

  )

)

And this would also convert the object into a editable poly (only if SHIFT is pressed)
So, you could use the same code to generate mesh or poly as the need be :

 
macroScript ResetXForm category:"reseting" 
(
	 on isEnabled return selection.count > 0
	 on execute do 
	 (
	 $.pivot = [0,0,0]
	 resetXForm selection
	 collapseStack selection
	 if keyboard.shiftPressed then (convertTo selection PolyMeshObject)
	 )
)

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

Since there is no way to be sure the selection is actually containing geometry, you might at least want to put the last line in try()catch() trap to avoid errors from helpers and such.
Both .pivot and resetXForm work on any node, but these nodes could have anything as base object.

oops …
thanks, bobo

 
macroScript ResetXForm category:"reseting" 
(
	 on isEnabled return selection.count > 0
	 on execute do 
	 (
	   $.pivot = [0,0,0]
	   resetXForm selection
	   collapseStack selection
	   try( if keyboard.shiftPressed then (convertTo selection PolyMeshObject) )catch()
	 )
)