ScriptSpot

Forum topic · General Scripting

Run a script to all objects

By caebrasil · 2011-01-26

Description

Hi, Continuing with my simple questions about maxscript, I did myself (not easy for me) this very simple script, to apply an Edit Poly after the Base Object and execute the Quadrify command.

It works great for me, but I want to do it to the entire scene, or all selected objects. But, how to do it?

My script:

(
max modify mode
modPanel.setCurrentObject $.baseObject
macros.run "Modifiers" "EditPolyMod"
macros.run "PolyTools" "Quadrify"
)

Comments (7)

renaming modifier

caebrasil · 2011-01-28

Ok, I want to do just one more thing:
How can I rename the new Edit Poly created? I want to rename "Edit Poly" to "Edit Poly Quad"...

use .name prop

Anubis · 2011-01-28

max modify mode
objs = getCurrentSelection()
for o in objs do
(
	modPanel.setCurrentObject o.baseObject
	macros.run "Modifiers" "EditPolyMod"
	macros.run "PolyTools" "Quadrify"
	o.modifiers[o.modifiers.count].name = "Edit Poly Quad"
)

perfect!

caebrasil · 2011-01-28

again, thank you Anubis!

caebrasil · 2011-01-26

Both works smoothly, THANK YOU!

loop through selected...

Anubis · 2011-01-26

max modify mode
objs = getCurrentSelection()
for o in objs do
(
	modPanel.setCurrentObject o.baseObject
	macros.run "Modifiers" "EditPolyMod"
	macros.run "PolyTools" "Quadrify"
)

woops, forgot to refresh the page before post :)

--for selected

br0t · 2011-01-26


--for selected objects:
theSel = selection as Array
for s in theSel do
(
   max modify mode
   modPanel.setCurrentObject s.baseObject
   macros.run "Modifiers" "EditPolyMod"
   macros.run "PolyTools" "Quadrify"
)
--for all objects in the scene:
for o in objects do
(
   ...
)

Cheers

caebrasil · 2011-01-27

br0t, your simple explanation just open my mind! I can apply this for a lot of tasks I do repeatedly!
Definitively, I need to study maxscript.
Again, thank you!