[Maya][Python] PolyAutoProjection


I’m new to Maya AND to python. I’m trying to do something quite simple, but I can’t figure out how is this thing working. I’m trying to apply the automatic projection on my selected faces inside one of my script.

If I look at the code maya produce when I hit the Automatic projection button, it looks like this:

polyAutoProjection -lm 0 -pb 0 -ibd 1 -cm 0 -l 2 -sc 1 -o 1 -p 6 -ps 0.2 -ws 0 pCube1.f[0:1] pCube1.f[5]

I get my selected faces this way:

import pymel.core as pm

faces = pm.ls(sl = True, fl = True)

but then I don’t know how I pass this array in the pm.polyAutoProjection() function…

This is not working
#pm.polyAutoProjection( pm.selected()[0], lm = 0, pb= 0, ibd = 1, cm = 0 , l = 2,sc = 1, o = 1, p = 6, ps = 0.2, ws = 0, ch = 1, faces )

I can’t do a for loop and do the projection for each face because the result is bad obviously.

how do you do that so it does the same as if I press the Automatic Projection button?



This might work, totally untested.

pm.polyAutoProjection(faces, lm=0, pb=0, ibd=1, cm=0, l=2, sc=1, o=1, p=6, ps=0.2, ws=0, ch=1)


I thought I tried that one, but looks like I didn’t because it works! thanks :slight_smile: