Select mirrored UV shells in maya .

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  02 February 2014
Select mirrored or stacked UV shells in maya?

Hey, I'm curious if someone knows of a maya script that can select UV shells that are mirrored or stacked in the UV layout?

I'm working on a weapon model and I usually create a "bake target" for baking textures to where I displace the overlapping/mirrored UVs temporarily for baking purposes. This is usually part of the process so not that big of a deal, but somehow I removed my bake target from the scene this time by accident.

So now I don't feel like going through my UVs and selecting each and every shell that is overlapping and moving it out of 0-1 space.

And thus I was hoping to find some kind soul out there that has a script that can do this already? Anyone?

Last edited by ChrisDeKitchen : 02 February 2014 at 07:44 PM.
  02 February 2014
If selecting the mirrored/overlapping faces isn't too time consuming, you can ctrl+right click>To UV
  02 February 2014
Have you checked the plethora of UV tool sets on creativecrash, one of them is bound to have this.
If not, give me a holla.
  02 February 2014
I'm curious how you approached this problem, Paul. Is python fast enough to handle something like this? Or did you use the API?
  02 February 2014
python commands are fast enough
one way to implemented it is to just leave one shell of the selected shells and move the rest, the user still needs to select a set of shells, but that's very quick.

The full monte is determine what shells are overlapping within some tolerances.
-convert the selection to faces
-get a list of faces per shell
-gather info for each shell, it's UV bounds and what ever else you want to use to determine overlap, like total area, uv count, center, etc
-sort the list of shells using the info you've gathered
-for each shell if the last shell and the current shells info are within tolerance, add the current shell to the set with the last, if not, put it in a new set
-for each shell set leave one shell move the rest.
  02 February 2014
I found the tricky part for me was getting the shells quickly. More than a few searches referenced Owen Burgess' post on Maya Station:

I simply modified his getuvshells script to return the values in 'uvShellArray'. From there I could easily determine which uvs belonged to each shell. Lastly, I determined overlap via centroid as you suggested.
  02 February 2014
@jgibz - nice! for forever I was using this shitty method with selection constraints to find the shells, but recently wrote a method using MFnMesh.getUvShellsIds to do the same, huge speed improvement.

o the ugliness
def getShells(sel):
	if sel:
		cmds.setToolTo('selectSuperContext') #TODO - hide uv editor b/c this uses selections cmds.polyListComponentConversion( sel, tf=1 ) , fl=1 )
		while len(biglist) > 0: biglist[0], r=1 )
			cmds.polySelectConstraint(sh=0,m=0) sl=1, fl=1 )
			shells.append( aShell )
			biglist=list( set(biglist) - set(aShell) )
		return shells # [ [faces in uv shell 1], [faces in shell 2], [etc] ]

used this as my shell heuristics sorting method
def uvp_shellSetify(shellSet, tol=[0.0,0.0,0.0]):
	#sort shells by area, boundSize, piv
	#shell in list=shell(1) and next shell(2) if next shells similar;
	#fract(piv1)==fract(piv2)+or-%		check option
	pivTol=tol[0] #0.005
	#bound1==bound2+or-%				check option
	boundTol=tol[1] #0.1
	#area1==area2+or-%					check option
	areaTol=tol[2] #0.5
	shellSet=sorted(shellSet, key=op.itemgetter(-1)) #area
	shellSet=sorted(shellSet, key=lambda a: (a[-2][0][1]-a[-2][0][0])*(a[-2][1][1]-a[-2][1][0]) ) #bound Size
	shellSet=sorted(shellSet, key=lambda a: a[-2][0][0]+((a[-2][0][1]-a[-2][0][0])*0.5) ) #piv, center bound U
	shellSet=sorted(shellSet, key=lambda a: a[-2][1][0]+((a[-2][1][1]-a[-2][1][0])*0.5) ) #piv, center bound V
	for i in range(len(shellSet)-1):
		piv1=[ shell1[-2][0][0]+(bUsize1*0.5), shell1[-2][1][0]+(bVsize1*0.5)]
		piv2=[shell2[-2][0][0]+(bUsize2*0.5), shell2[-2][1][0]+(bVsize2*0.5)]
		pivD = math.sqrt( ((piv1[0]-piv2[0])*(piv1[0]-piv2[0]))+((piv1[1]-piv2[1])*(piv1[1]-piv2[1])) )
		if pivD<pivTol:												#center pivot is close enough
			if bUsize2<bUsize1+(bUsize1*boundTol):	#bound U size is percentage of size close enough
				if bVsize2<bVsize1+(bVsize1*boundTol):#bound V size is percentage of size close enough
					if area2<area1+area1*areaTol:
		if isSet==False:
	for i in range(len(sharedShellSet)):
	return shellSet
  02 February 2014
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 03:13 AM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.