Notifications
Clear all

[Closed] Reset X, Pivot and Collapse

Hello you scripters,

Ive started to try out some maxscripting today. Very very interesting stuff.

I am trying to create a script that combines 3 actions in 1. I have searched my ass off on google and these boards for some tips and came up with some commands but I think I’m doing something wrong when I combine it and link it to a button.

What I want the script to do: I have created a scene and I want all models in this scene to: “Reset X-form, Align pivot to 0-axis and Collapse stack to editablepoly modifier”
and I would like to link this command to a button in or outside a rollout.

What script am I using currently:

rollout ResetXPivotnCollapse "ResetXPivotnCollapse" width:162 height:57
(
	groupBox grp1 "Reset X-Form" pos:[4,7] width:154 height:46
	button ResetXForm "ResetXForm" pos:[43,26] width:77 height:21

		

	on ResetXForm pressed do
(
		o.pivot = [0,0,0]
		ResetXform(o)
		collapseStack(o) selection
	)
)
objEd = newRolloutFloater "ResetXPivotCollapse" 250 450 50 50
addrollout vertSnap objEd 

Error: –Type error: Call needs function or class, got: ButtonControl:ResetXform

Any ideas.

t.i.a.

5 Replies
 	
   rollout ResetXPivotnCollapse "ResetXPivotnCollapse" width:162 height:57
(
	groupBox grp1 "Reset X-Form" pos:[4,7] width:154 height:46
	button Reset_XForm "ResetXForm" pos:[43,26] width:77 height:21

		

	on Reset_XForm pressed do
(
	for o in selection do (
		o.pivot = [0,0,0]
		ResetXform (o) 
		collapseStack o --selection
	)
	
)
)
objEd = newRolloutFloater "ResetXPivotCollapse" 250 450 50 50
addrollout ResetXPivotnCollapse objEd

-Do not use a modifier name as a button identifier
this is not valid , i changed the dentifier to reset_xform

-you need to select the objects before you press the script button .

-instead of newRolloutFloater you can simply do

rollout test “test”
(

your code here
)

createDialog test

newRolloutFloater is usually used when you have lots of controls to add and don’t want them displayed all the time

check the last line … you were adding a rollout that didn’t exist to the objEd

Awesome, thanks for the comment.

Your script works like a charm, except for one thing, everything becomes an
editable mesh, which variable did you change for that? I need everything to become an editable poly after collapse.

And second question:
If I use your code with the rollout script like you said, thus like this:

rollout test "test"
(
	
rollout ResetXPivotnCollapse "ResetXPivotnCollapse" width:162 height:57
(
	groupBox grp1 "Reset X-Form" pos:[4,7] width:154 height:46
	button Reset_XForm "ResetXForm" pos:[43,26] width:77 height:21

		

	on Reset_XForm pressed do
(
	for o in selection do (
		o.pivot = [0,0,0]
		ResetXform (o) 
		collapseStack o --selection
	)
	
)
)
)

createDialog test 

When I run the script, the popup seems to be empty! I mustve understood wrong I guess, which part of the code goes into where?

Okay Fixed it, I think!

rollout ResetXPivotnCollapse "ResetXPivotnCollapse" width:162 height:57
(
	groupBox grp1 "Reset X-Form" pos:[4,7] width:154 height:46
	button Reset_XForm "ResetXForm" pos:[43,26] width:77 height:21

		

	on Reset_XForm pressed do
(
	for o in selection do (
		o.pivot = [0,0,0]
		ResetXform (o) 
		collapseStack o --selection
	)
	
)
)


createDialog ResetXPivotnCollapse 

However, the models still become editablemeshes, UNLESS they have previously been modified to an editablepoly modifier. How can I adjust this variable?

Once again thank you very much Cyfer!

make a teapot
add a xform modifier and collapse
you’ll get a mesh !
that’s exactly what you do in your script
if you need every thing to be editablePoly you can add this line

converttopoly o

now it should look like

for o in selection do (
o.pivot = [0,0,0]
ResetXform (o)
collapseStack o
converttopoly o
)

  • i was wrong … don’t use Reset_Xform as a button identifier , its a reserved word for max
    and its a bad practice to do it , it will work but you shouldn’t use it
    making it TheResetXform or ResetTheXform is fine

please see these sections in the documentation

-Selection
-array
-for loop
-node general parameters

these will help you get what this script does

  • Renamed the button identifier

P e r f e c t script cyfer, thank you very much. Ive learned a lot.

Will check out the documentation, plus I will search for some good books on maxscript.