Reset Xref/Collapse/Edit Poly

I’m a big fan of speeding up my workflow as much as possible… I’m not great with scripting but I get by with basic skills.

One thing I’ve never been able to figure out is how to make a multi-command script (accessible by toolbar button OR hotkey OR both?) is:

  • (with selected object)
  • Reset Xref, then
  • Collapse, then
  • Convert to Edit Poly

I find myself doing this hundreds of times when setting up a new imported file.

Does this tool exist? If not, are there any super smart scripters out there that can quickly help me out?

Thanks for any tips!

I assume you mean Reset Xform instead of Reset Xref?

You could do this for multiple objects by using this code:


for obj in selection do
(
  ResetXForm obj
  ConvertToPoly obj
)

Copy this into your Maxscript editor:
editor.png

Then drag and drop to your toolbar, it will create a button
drag.png

You can then right click on that button, change the icon/name etc.

Hi James - you are indeed right with your assumption… ugh I’m obviously tired…

I’ll test this out and let you know how I go. A million thanks for the help mate!

No probs

Oddly enough, every time I drag into the toolbar Max decides to crash.

I’ve made previous little script toolbar buttons with the following code (and adding the toolbar button via the settings)

macroScript ‘NAME’
category:“AAScripts”
toolTip:“”
( code here
)

I tried adapting this with your code but getting errors.

Any idea where I’m going wrong?

Did you drag and drop the exact code I wrote? Or did you edit it with your code?

I suggest copy it as I have first, test that if it works, if it crashes let me know.

Also which 3dsmax version are you using?

FYI if you are going to put your code then you need to evaluate the script, drag and drop wont work, it only works for code without the header, so for example:


macroScript ResetAndCollapse
   category:"AAScripts"
   toolTip:"ResetAndCollapse"

(
	for obj in selection do
	(
	  ResetXForm obj
	  ConvertToPoly obj
	)
)

Once this is in your Editor you press CTRL+E (not drag and drop).

You can then go to Customize > Customize User Interface > Toolbars
toolbar.png

Yes, was crashing with your code exactly.

Very odd.

Max 2023.1

When I try to run it with my own code (below) this is the error:

  • Runtime error: ResetXForm requires a node
macroScript AAResetXformCollapse
	category:"1AAScripts"
	toolTip:""
for obj in selection do
(
  	ResetXForm obj
  	ConvertToPoly obj

)

you are missing another set of parenthesis, check my code above. I don’t use 3dsmax 2023, so if its still an issue after using the additional parenthesis you might need someone who’s using the latest version to help.

P.S. I don’t think it’s your code that’s causing the crash but rather something buggy with my max…

Make sure you add the additional parenthesis:


macroScript ResetAndCollapse
   category:"AAScripts"
   toolTip:"ResetAndCollapse"

(
	for obj in selection do
	(
	  ResetXForm obj
	  ConvertToPoly obj
	)
)

btw soulburnscripts has this functionality too:

Doesn’t seem to work with 2023 unfortunately.

(Or, it is crashing for me, at least).

Hi,

I am SO sorry to be one of those annoying-people-you’re-helping-with-nothing-in-return… BUT

Please see attached screencapture.

Either I’m doing something wrong, or something buggy is up with my max. Either is very likely…

Can you spot a problem? Thanks again James you’re skills are impressive

I use transform toolbox for this. It lets you reset transforms without adding modifier in the stack. Single press of a button and no need to constantly go to utilities panel and collapsing the stack. On top of that it also has some quick pivot alignment and other useful tools. I always summon this window at the start of modelling sessions and park it somewhere in the corner. I would permanently dock it in a toolbar, but unfortunately that way it creates too much wasted space.

Doesn’t seem to work with 2023 unfortunately.

(Or, it is crashing for me, at least).

works fine in 2023.1 here…

Damn… obviously something up with my max then. Very curious infuriating…

Thanks for the suggestion and follow-up.

Hm, I was just reading that the convert editable poly could have different syntax in 2023, you could try this but its a long shot.


for obj in selection do 
(
  resetXForm obj
  convert obj #editable_poly
)

I think someone using 3dsmax 2023 could debug this one better than I could at this stage.

edit:
I had polymesh before, I updated it to editable_poly, apparently you can use these… ‘polymesh’,‘editable_mesh’,‘editable_poly’ etc.
The reset xform could also be different in 3dsmax 2023…

This won’t help you with writing your own script, but in case you’re also looking for a solution to this, Assembly Tool Plugin (free) has a function that does exactly what you described.
It’s called “Prepare Models for Work”

If it is not working, you are most probably missing the “on execute” line.
Here is the script I wrote for exactly this, it also brings the pivot to XY center and Z min:


macroscript My_macro category:"Aram Avetisyan" tooltip:"Xform, Poly, Pivot XY Center Z Min"
(
 on execute do
 (
	 for _ in $ do
	 (
		 resetxform _
		 convertTo _ EditablePolyMesh
		 _.pivot = [_.center.x, _.center.y, _.min.z]
	 )
 )
max modify mode 
)

You can then assign a hotkey for it in Hotkey manager.

Cheers.

Wow, this one works. Thanks mate.

One issue; it doesn’t to the Collapse of multiple objects though. Do you think this is somehow possible?