## Moving Pivots in Maya/Python

Help
Carlos
2007-01-06
2013-03-24

• Carlos
2007-01-06

Hi Matthias,

I'm trying to move the pivot of a plane to a vertex in this case vertex 2, the thing works in mel, but Im having  a hard time with the translation to maya/python.

The mel code looks like:

polyPlane -w 10 -h 10 -sx 1 -sy 1 -ax 0 1 0 -cuv 2 -ch 1;

move 5 0 5

float \$posn[3];

\$posn = `pointPosition -w Plot.vtx[2]`;

move -a \$posn[0] \$posn[1] \$posn[2] Plot.scalePivot Plot.rotatePivot ;

FreezeTransformations;

The real problem is with lines 3 to 5, the rest is trivial.

The first issue is with posn, in mel the result is 0 0 0, but in python it gives [0.0, 1.1102230246251565e-015, 0.0]
The next problem is moving the pivot, I still don't get how to pass this type of arguments, and as a result the pivot doesn't move...

I was trying this in python:

select(all = None)

delete()

W = 10

H = 10

myPlane = polyPlane (w = W, h = H, sx = 1, sy = 1, ax = (0,1,0), cuv = 2, ch = 1)

move(W/2, 0, H/2)

# This gives an different result [0.0, 1.1102230246251565e-015, 0.0]
posn = pointPosition(w = '%s.vtx[2]' %(myPlane[0]))

# My options didn't work
move(a = (posn[0], posn[1], posn[2]), ' %s.scalePivot %s.rotatePivot' % (myPlane[0], myPlane[0]))
#move('-a %i %i %i %s.scalePivot %s.rotatePivot' % (posn[0], posn[1], posn[2], myPlane[0], myPlane[0]))
#move(a = '%i %i %i %s.scalePivot %s.rotatePivot' % (posn[0], posn[1], posn[2], myPlane[0], myPlane[0]))

FreezeTransformations()

Can you give me a hand?

And by the way, normally I get the following errors:

SyntaxError: non-keyword arg after keyword arg
Error string: "(kFailure): Unexpected Internal Failure".

Is there a place were I can find out what those mean?

Thanks,
Carlos

• Carlos
2007-01-10

Hmm nevermind I solved it with Xform

Thanks