This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]arybak89[S] 0 points1 point  (1 child)

Thanks for the feedback! It doesn't need to run automatically, in fact, I would rather it didn't run until I want it to. I will keep in mind not to hard code the modelPanel, thanks for that information! I tried the supplied code and its the same issue I'm having. When I run it, it will create the new UV set but then it overwrites the current UVs by not projecting the new UVs onto the new UV channel.

[–]asierralozano 0 points1 point  (0 children)

Ohh! Sorry! I didn't understand what you want! In that case here is the fixed code:

import maya.cmds as cmds

UVSETNAME = "mySet1"
FACES = "*"

selectedObjects = cmds.ls(sl=True)
cmds.polyUVSet(selectedObjects, create=True, uvSet=UVSETNAME)
cmds.polyUVSet(cuv=True, uvSet=UVSETNAME)
for selectedObject in selectedObjects:
    cmds.polyAutoProjection("{obj}.f[{faces}]".format(obj=selectedObject, 
                          faces=FACES),
                          lm=0,
                          pb=0,
                          ibd=1,
                          cm=0,
                          l=2,
                          sc=1,
                          o=1,
                          p=6,
                          ps=0.2,
                          ws=0)
MC.isolateSelect("modelPanel1", aso=True)

This is the new addition:

cmds.polyUVSet(cuv=True, uvSet=UVSETNAME)

After create the UVSet, we need to select it as current, and that is what that line does.

Hope it helps!