Move and Rotate UV shell after Flatten mapping

Hi everyone,

this is my first post here even if I am often looking at htis website to get answers :)

i am not a "scriptor" at all but for fex weeks I tried to make some tools that optimize my process at work.
Currently I managed few on them by calling modifier and so.

I got one big trouble right now.
For one of my script I was using the benefit of "Strip" Uv on the shell modifier but unfortunately this one is not perfect (perfect strip but bad ratio) so I tried a new method to unwrap these strip.

Currently what I did is to apply a flatten mapping by ID:
-- temp.flattenMapByMatID 1 0 false 0 false false

but now I need a script to place all the UV Shell to 0.0.0 in absolute mod.

So I want to say:
Select first UV shell element
then place it to 0.0.0
Select second UV Shell element
then place it to 0.0.0
...
this thnig for each UV shell

I am pretty sure I need to use an array but honestly i don't kno how to do it properly and even I have never manage to move my Uv shell to 0.0.0 after many many tries.

Can you help me to do it? :)

This is less important but in a perfect world I would like to rotate them in the same direction also (actually I guess I shold rotate them before to move them).
Currently the flatten mapping method orient my UV shells as on my geometry (I guess) but I would like to get them in the same direction maybe by evaluate the lenght of each one (they have exactly the same width but different length).

Alright, I know my English isn't as good as it should and my question is maybe to confusing. let me know if you want more details.

regards,

Comments

Comment viewing options

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

Thanks to both of you

Thanks to both of you guys.

miauu: I just use the "face part" of your script and that works perfectly well so thank you again.
After that I needed to fix many others things over my script but finally I got something that does the job.

It's pretty hard to understand how works maxscript compare to some other language but it is also probably because I am not enough use to practice coding.

jahman's picture

.

I am pretty sure I need to use an array but honestly i don't kno how to do it properly...

Basic maxscript knowledge won't be enough to accomplish such task.
If you really wan't to try first of all figure out which faces belong to which uv-shell.

miauu's picture

.

The code below is a modifiation of one of mine scripts.
Select your object, assign UVWUnwrap modifier(if it is not assigned yet), open the Edit UVWs window, select all verts or edges or faces of the UVs and run the script and press the button. If you select only one vert/edge/face of one or two UV islands the script will move only those UV islands.

(
	global rol_uvToZero
	try(destroyDialog rol_uvToZero)catch()
	rollout rol_uvToZero "UVs to [0,0,0]"
	(
 
		button btn_moveUVs "Move selected UVs to [0,0,0]" -- width:
 
		on btn_moveUVs pressed do
		(
			uvIslands = #()
			uv = modpanel.getcurrentobject()
			if classof (uv) == Unwrap_UVW then
			(
				uvIslands = #()
				subObjLevel = uv.getTVsubobjectMode()
				case subObjLevel of
				(
					1: 
					(
						allVerts = uv.getSelectedVertices()
						if not allVerts.isEmpty do
						(
							while not allVerts.isEmpty do
							(				
								uv.selectVertices #{(allVerts as array)[1]}
								uv.SelectElement()
								elem01verts = uv.getSelectedVertices()
								append uvIslands elem01verts
								allVerts = allVerts-elem01verts
							)
						)
					)
					2:
					(
						allEdges = uv.getSelectedEdges()
						if not allEdges.isEmpty do
						(
							while not allEdges.isEmpty do
							(
								uv.selectEdges #{(allEdges as array)[1]}
								uv.SelectElement()
								elem01verts = uv.getSelectedEdges()
								append uvIslands elem01verts
								allEdges = allEdges-elem01verts
							)
						)
					)
					3:
					(
						allFaces = uv.getSelectedFaces()
						if not allFaces.isEmpty do
						(
							while not allFaces.isEmpty do
							(
								uv.selectFaces #{(allFaces as array)[1]}
								uv.SelectElement()
								elem01faces = uv.getSelectedFaces()
								append uvIslands elem01faces
								allFaces = allFaces-elem01faces
							)
						)
					)
				)	
				if uvIslands.count != 0 do with undo "UVs to [0,0,0]" on
				(
					case subObjLevel of 
					(
						1: 
						(
							for i=1 to uvIslands.count do
							(
								uv.selectVertices uvIslands[i]
								uv.moveSelected ([0,0,0] - uv.getSelCenter())
							)
						)
						2: 
						(
							for i=1 to uvIslands.count do
							(
								uv.selectEdges uvIslands[i]
								uv.moveSelected ([0,0,0] - uv.getSelCenter())
							)
						)
						3: 
						(
							for i=1 to uvIslands.count do
							(
								uv.selectFaces uvIslands[i]
								uv.moveSelected ([0,0,0] - uv.getSelCenter())
							)
						)
					)
				)
 
			)
			else
			(
				messagebox "Open the \"Edit UVWs\" window!" title:"miauu Script Error!!!"
				chkbtn_holdSelection.state = false
			)
		)
	)
	createdialog rol_uvToZero 	
 
)

Comment viewing options

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