ScriptSpot

Forum topic · General Scripting

multiple modifiers on multiple objects

By troyharder · 2016-06-12

Description

Hi Guys,

I'm Looking to figure out a way to add a set of modifiers (in this case a UVW Box Map with 1mx1mx1m followed by a material modifier to several selected objects).

It would be super cool to have it applied to a quad menu, but I suppose that should work if you make it a macroscript and then costumize the quads to include the written macroscript.

Tried something like this:

macroScript Macro1
category:"DragAndDrop"
toolTip:""
(
modPanel.addModToSelection (Uvwmap ()) ui:on
$.modifiers[#UVW_Map].maptype = 4
$.modifiers[#UVW_Map].length = 100
$.modifiers[#UVW_Map].width = 100
$.modifiers[#UVW_Map].height = 100
modPanel.addModToSelection (Materialmodifier ()) ui:on
)

But it only works for individual objects, unfortunately

Thanks for your help, this is my 1st attempt at scripting.

Comments (4)

troyharder · 2020-11-26

Dear Barigazy, thank you for your input and apologies for my fossilizingly late reply.
I did manage to get it done in the end by applying simply a modifier to a selection, and then applying another one. :)
they were all nicely instanced and controllable by selecting a simple object and applying changes to all in each of the instanced modifiers.
None the less, many thanks! :)

fajar · 2016-06-15

or you just can add this line ..


macroScript AddUVW
category:"YourCatagoryName"
tooltip:"Add UVW to Selection"
buttontext:"Add UVW to Selection"

(
local uvwMod = Uvwmap maptype:4 length:100 width:100 height:100
suspendEditing()
modPanel.addModToSelection (uvwMod) ui:on
resumeEditing()
)

barigazy · 2016-06-13

This is what you want. If you press SHIFT then all modifier are copy or with single click you have all modifiers as instance

macroScript UvwPlusMtlMod category:"bgaTools" toolTip:"uvw100"
(
if selection.count > 0 do
(
local uvwMod = Uvwmap maptype:4 length:100 width:100 height:100
local mtlMod = Materialmodifier ()
for o in selection where canconvertto o editable_poly do
(
addModifier o (if keyboard.shiftPressed then copy uvwMod else uvwMod)
addModifier o (if keyboard.shiftPressed then copy mtlMod else mtlMod)
)
)
)

barigazy · 2016-06-13

Don't try to copy from Listener or drag-drop chank of code to your toolbar. It's always better to find right solution in MXS Help documentation.