Rotate UVWMap gizmo a selection of object

Hello everyone :)

How do I rotate the gizmo a modifier UVWMap in a selection of object?

Scenario:

I have 10 box and I apply to each a modifier UVWMap.
I want rotate the gizmo UVWmap to each object of 90° (or other
value) randomly pressing a button so as to have 10 objects with different rotation mapping.

My example dont work...

rollout t "Test"
(
	local mymod = (UVWMap())
 
	button b "Create UVWMap"
	button b2 "Random"
 
	on b pressed do
	(
	addmod =  for i in selection do addModifier i (UVWMap()) ui:on
         )
 
        on b2 pressed do 
              (
	     giz = mymod.gizmo
             giz.rotation = (angleaxis -90 [0,0,1]) as quat
                 )
 
)
createdialog t

If I select only one object the script works in half (the button dont refresh the value every time I press it) and if I select all object, i have this error message:

>> MAXScript Rollout Handler Exception: -- Unknown property: "gizmo" in Uvwmap:UVW Mapping <<

Can you help me? I can not find a solution....

Thanks

Comments

Comment viewing options

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

Yes Joker it's all right !!

Yes Joker it's all right !! :) Thanks!!!!!!!!

The only problem is:

How to If I want rotate the uvwmap a defined value (es. 90° or 45° ecc.)always random
for all object?

Anyway thanks again! :)

Anubis's picture

Hi Michele, if I see, you

Hi Michele,
if I see, you need to choose random value between concrete vals like 45 and 90. If so, put them to array and use random index to select an item from.

a = #(-90, -45, 45, 90)
r = a[random 1 4]

my recent MAXScripts RSS (archive here)

Michele71's picture

Hi Anubis, Thanks for you

Hi Anubis, Thanks for you reply :)

Yes, now it's all right! I never thought of using an array to construct a random
value...this advice I will be very useful, this is a great tip that I will always remember ;)

Thanks again Anubis

JokerMartini's picture

Here you go!

rollout t "Test"
(
	local mymod = (UVWMap())
 
	button b "Create UVWMap"
	button b2 "Random"
 
	on b pressed do
	(
		mapMod = UVWMap maptype:4
		addmod =  for i in selection do addModifier i (mapMod) ui:on
	)
 
	on b2 pressed do 
	(
		for i = 1 to selection.count do
		(
			obj = selection[i]
			giz =obj.modifiers[1].gizmo
			val = (random -360 360)
			giz.rotation = (angleaxis val [1,1,1]) as quat
		)
	)
 
)
createdialog t

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

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