Find object with no UV coordinates

Find object with no UV coordinates

Anonymous
Not applicable
1,403 Views
5 Replies
Message 1 of 6

Find object with no UV coordinates

Anonymous
Not applicable

I'm writing a Python script to determine if an object has UV coordinates or not. - by counting the UVshells.

This should be straight forward. 

import maya.cmds as cmds

cmds.cube( n ='cubey' )

# number of UV shells
UV = cmds.polyEvaluate( uvShell=True )
print UV

 

Only I get the error:

TypeError: file <maya console> line 6: Invalid flag 'uvShell' #

 

So I'm a little confused since the above is used as an example in the docs😲

0 Likes
Accepted solutions (1)
1,404 Views
5 Replies
Replies (5)
Message 2 of 6

mspeer
Consultant
Consultant

Hi!

 

What Maya version are you using?

Here it works, except for your cube creation which should be

cmds.polyCube( n ='cubey' )
0 Likes
Message 3 of 6

Anonymous
Not applicable

Maya 2017

0 Likes
Message 4 of 6

mspeer
Consultant
Consultant
Accepted solution

Hi!

Please check the documentation, Maya 2017 does not support this flag,

it was added in Maya 2018.

So you need to use Maya 2018 or any other script.

 

I recommend to try

 

cmds.polyEvaluate( uvcoord=True )

If the result is "0", there are no UV coordinates (for the current UV Set) and this also works in Maya 2017

 

0 Likes
Message 5 of 6

olarn
Advocate
Advocate

Would counting the number of UV points instead works in your case?

import pymel.core as pm
obj = pm.PyNode("pTorus1").getShape()
has_any_uv_current_set = obj.numUVs() > 0
print(has_any_uv_current_set)

 

0 Likes
Message 6 of 6

Anonymous
Not applicable

That may wee work, the minor adjustment in the code above works for me 🙂

0 Likes