add an instanted modifier

hello

I would like to add a edit poly modifier as first modifier of selected base objects as instance.

for i in $* do
(
modPanel.setCurrentObject i
modPanel.addModToSelection (Edit_Poly ()) ui:off
)

this add a modifier but not as instance....
Can anybody help ?

Thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Graph's picture

weird it should handle

weird it should handle collections like and array tho, are you in a version earlier than 2010?
also if you wanna use the shortcut you can use $ only no * needed. but you shouldnt use that as it is just a ref target when only 1 object is selected afair
also: to make it faster put the selection array into a local var then it doesnt have to convert it to an array every itteration ;)
to make it another notch faster you should use the addModifier function it doesnt require max command panels to be in modify mode (waaay faster) also the object does not have to be selected.
if you wanna work inside the mod after assigning i suggest 2 loops 1 for assigning them the fastest way and another to modify the selected object in max modify mode (that overall should be faster)
reason create mode is faster than modify mode is "that it doesnt have to fully eval the modifier stack when switching objects in create mode"

Raphael Steves

titane357's picture

Thanks for answer Insanto, I

Thanks for answer Insanto,
I don't think I can use addModifier fonction as I want to add my modifier not in top but in botton of the stack.
Not very fast, but now it worKs... (maxdesign2011) I will try to make it better...
My problem is now :
- I can I select all objects which share same instanced modifier (here editpoly)
- How can I "collapse to" this instanced modifier (which is on bottom stack) on all objects which don't have same number of modifier in their stack ?
Cheers

titane357's picture

Now it works : ( local

Now it works :
(
local polyMod = Edit_Poly()
for obj in (selection as array) do
(
modPanel.setCurrentObject obj
modPanel.addModToSelection polyMod ui:off
)
)

titane357's picture

In fact, I can't manage to

In fact, I can't manage to make it work on selected objects... just on all :-((

titane357's picture

Thanks for answer it helps me

Thanks for answer it helps me a lot :-)
so, I have now what I was looking for :
(
local polyMod = Edit_Poly()
for obj in $* do
(
modPanel.setCurrentObject obj
modPanel.addModToSelection polyMod ui:off
)
)

I don't know why "in selection" don't work and I need to write "in $*" ?!?
cheers

Graph's picture

( local polyMod =

(
  local polyMod = Edit_Poly()
 
  for obj in selection do
  (
    addmodifier obj polyMod
  )
)

or

(
  local polyMod = Edit_Poly()
 
  addmodifier selection polyMod
)

or

(
  addmodifier selection (Edit_Poly())
)

if you loop through the objects you gotta save the mod in a var but not if you add the mod with a mapped function as you only supply the one

Raphael Steves

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.