ScriptSpot

Forum topic · General Scripting

Rotate uvmap random 90 degree

By Dragan_ilic · 2019-03-20

Description

Hello community,
I need a little help and i hope someone can help me :), in my script i want to rotate the uvmap by 90 degree steps and i coundnt figure out how to do it.
At the moment the script are rotating the uvmap in 360 degree, but in smaller steps not just 90 degree steps.
Has someone an idea?

thx Dragan


rollout UVmaprot "Rotate random uvmap"
(

	button uvrot "Random rotate uvmap"
 
	on uvrot pressed do 
	(
		for i = 1 to selection.count do
		(
			obj = selection[i]
			gizm =obj.modifiers[1].gizmo
			valrot = random -360 360
			gizm.rotation = (angleaxis valrot [0,0,1]) 
		)
	)
 
)
createdialog UVmaprot 
Comments (2)

barigazy · 2019-04-07

Hi "Zemljak" ;)
with this you can rotate in any axis by 90 degrees

try(destroyDialog ::UVmaprot)catch()
rollout UVmaprot "UVmaprot"
(
local val = #(-270,-180,-90,0,90,180,270)
checkbutton cbtn_x "X" width:32 height:18 pos:[5,5] highlightColor:[176,26,26]
checkbutton cbtn_y "Y" width:32 height:18 pos:[39,5] highlightColor:[6,135,6]
checkbutton cbtn_z "Z" width:32 height:18 pos:[73,5] highlightColor:[8,61,136]
button btn_uvrot "Random Rotate UV" width:100 height:18 pos:[5,25]

on btn_uvrot pressed do if selection.count > 0 do
(
for node in selection where isProperty node #uvwmap do
(
if cbtn_x.checked do node.uvwmap.gizmo.rotation = (angleaxis val[random 1 7] x_axis)
if cbtn_y.checked do node.uvwmap.gizmo.rotation = (angleaxis val[random 1 7] y_axis)
if cbtn_z.checked do node.uvwmap.gizmo.rotation = (angleaxis val[random 1 7] z_axis)
)
)
)
createDialog UVmaprot 110 50 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)

Dragan_ilic · 2019-04-12

Hvala :P