How can you apply the mod individually?

You can select multiple objects and apply a material to them. How ever apply a UVWmap modifier to the same selected objects the mod is applied to the group as a whole not independently.

This applies a cylindrical UVWmap to one object.

macros.run "Modifiers" "UVWmap"
$.modifiers[#UVW_Mapping].maptype = 1

How could you apply the mod to a select group individually?

Comments

Comment viewing options

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

try this one instead (Anubis

try this one instead (Anubis has probably a much better solution) ;o)
This keeps other modifiers in the stack and remove uvw map only.

-- Delete UVW Map Modifier in selection
	on btn_DeleteUVWMod pressed do
		(		
			for i in selection do
			(
			modPanel.setCurrentObject $.modifiers[#UVW_Map] 
			deleteModifier i i.uvw_Map
			)
 
 
		) -- End On

Raymond H.Ingebretsen - http://www.homme3d.com

Anubis's picture

about deleteModifier()

Yes, Tassel is right about deleting. Delete by index is not safe. Well, somehow ".uvw_Map" return error here, but ".UVW_Mapping" works fine --
for i in selection do (deleteModifier i i.UVW_Mapping)

my recent MAXScripts RSS (archive here)

othoap's picture

Doh

Good point. I didn't try it with other mods in the stack. How ever Now it adds two maps and will not delete ether.

othoap's picture

Update

Thanks to Tassel and Anubis for there update's

I rolled in "check for modifier compatibility" from Anubis. I also added a delete button.

--Destroy the dialog if it is already open 
try(destroyDialog roll_umm)catch()
 
-- UI STUFF
rollout roll_umm "UVW Multi Mapper"
(
group "UVW Map Type:"
	(
	radiobuttons rad_buttons "Map:" labels:#("Plane",  "Cylindrical",  "Cylindrical Cap", "Spherical", "Shrink Wrap", "Box", "Face", "xyz to UVW") default:0 columns:1
	)
	button btn_Add "Add" pos:[4,170] height:22 width:50 tooltip:"Add UVW map Modifier to selected objects" align:#center
	button btn_Delete "Delete" pos:[57,170]  height:22 width:50 tooltip:"Add UVW map Modifier to selected objects" align:#center
-- END UI STUFF
 
-- Radiobutton labels. Add UVW MapType
on rad_buttons changed state do (
	case state of
		(
		1: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:0)))
		2: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:1)))
		3: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:1 cap:on)))
		4: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:2)))
		5: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:3)))
		6: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:4)))
		7: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:5)))
		8: (for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:6)))
		)
) -- End On
 
-- Add UVW Map Modifier to selection
on btn_Add pressed do
	(
		for obj in selection do addModifier obj (uvwMap maptype:4)
	) -- End On
 
-- Delete UVW Map Modifier to selection
on btn_Delete pressed do
	(
	deleteModifier $ 1
	) -- End On
)
-- Create Dialog Stuff
createDialog roll_umm 110 200 pos:[1300,200] 
tassel's picture

Thank you for the info Anubis

Thank you for the info Anubis :)

Raymond H.Ingebretsen - http://www.homme3d.com

Anubis's picture

RE: small question

I see you done what you need, but as you ask about shapes - yes, they're separate category (not belong to Geometry).

Ah, and one more advise :)
GeometryClass is too large category that include standard and extended primitives, polys, meshes, compound and dynamics objects, targetObject, particles, patches, nurbs, bones, biped, CATs, conteiners, body, mr_Proxy, some DWG helpers ... etc.

In other words, more safety expression would be if you check for modifier compatibility, i.e. is concrete modifier applicable to selected object, something like:
for obj in selection where (validModifier obj uvwMap) do (addModifier obj (uvwMap maptype:4))

Cheers!

my recent MAXScripts RSS (archive here)

tassel's picture

A small question since this

A small question since this thread is about UV's:)

I tried to add a UVW map modifier to an spline object with this code (Dosn't work):

for obj in selection where superClassOf obj == geometryClass do (addModifier obj (uvwMap maptype:4))

But this works:

for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:4))

Any idee why? I thought splines/Shapes belonged to geometryClass ?

I ended up with modifying othoap's script to this:

--Destroy the dialog if it is already open 
try(destroyDialog roll_umm)catch()
 
-- UI STUFF
rollout roll_umm "UVW Multi Mapper"
(
		group "UVW Map Type:"
		(
			radiobuttons rad_buttons "Map:" labels:#("Plane",  "Cylindrical",  "Cylindrical Cap", "Spherical", "Shrink Wrap", "Box", "Face", "xyz to UVW") default:0 columns:1
		)
		button btn_AddUVWModifier "Add UVW Map Modifier" height:22 width:130 tooltip:"Add UVW map Modifier to selected objects" align:#center
-- END UI STUFF
 
-- Radiobutton labels. Add UVW MapType
		on rad_buttons changed state do (
			case state of
			(
				1: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:0)))
				2: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:1)))
				3: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:1 cap:on)))
				4: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:2)))
				5: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:3)))
				6: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:4)))
				7: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:5)))
				8: (for obj in selection where superClassOf obj == geometryClass or isKindOf obj Shape do (addModifier obj (uvwMap maptype:6)))
			)
		) -- End On
 
-- Add UVW Map Modifier to selection
		on btn_AddUVWModifier pressed do
		(
			for obj in selection do addModifier obj (uvwMap maptype:4)
		) -- End On
)
-- Create Dialog Stuff
createDialog roll_umm 140 200 pos:[1300,200] 

Raymond H.Ingebretsen - http://www.homme3d.com

Anubis's picture

uvwMap maptype:1 cap:on

You has made syntax mistake for .cap property.

(uvwMap maptype:1 .cap = on) -- wrong
(uvwMap maptype:1 cap:on) -- correct

When you create new node, modifier, material... you call their Constructor and all properties are optional and passed with "propName:Value" syntax. Once remember this, you'll have zero problems in the future ;)

Meanwhile, I post a script to Fit the UVWmap gizmo on existing modifiers:
http://www.scriptspot.com/3ds-max/scripts/fit-the-uvw-mapping-gizmo

Regards,
Anubis

my recent MAXScripts RSS (archive here)

othoap's picture

thanks you-all's

I got this to work with you-all's help - thanks Anubis

How ever # 3 cylinder capping dose not work.

rollout umm "uvMultiMapper"
(
	radiobuttons rad_buttons "Map:" pos:[0,0] labels:#("Pln",  "Cyl", "Cap", "Sph", "Shr", "Box", "Fac", "xyz") columns:1 
    on rad_buttons changed state do (
        case state of
        (
            1: (for obj in selection do addModifier obj (uvwMap maptype:0))
            2: (for obj in selection do addModifier obj (uvwMap maptype:1))
            3: (for obj in selection do addModifier obj (uvwMap maptype:1 .cap = on))
			4: (for obj in selection do addModifier obj (uvwMap maptype:2))
			5: (for obj in selection do addModifier obj (uvwMap maptype:3))
			6: (for obj in selection do addModifier obj (uvwMap maptype:4))
			7: (for obj in selection do addModifier obj (uvwMap maptype:5))
			8: (for obj in selection do addModifier obj (uvwMap maptype:6))
			9: (for obj in selection do addModifier obj (uvwMap maptype:7))	
        )
        --rad_buttons.enabled = true
    )
)
createDialog umm 40 140 pos:[1300,200] 
cui.RegisterDialogBar umm minSize:[40,140] maxSize:[40,140] style:#(#cui_floatable,#cui_dock_left,#cui_dock_right,#cui_handles)
Anubis's picture

Hi Othoap,

This works fine here (Max2009):
for obj in selection do addModifier obj (uvwMap maptype:4)
(all gizmos Fit their owner objs just fine)

my recent MAXScripts RSS (archive here)

Comment viewing options

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