Same python code works differently differently Maya (2012-2015)

this simple code

import maya.cmds as cmd

circle1 = cmd.circle(nr=(0, 0, 1), c=(0, -1.1, 0), ch=1)
circle2 = cmd.duplicate(circle1[0], ic=1)
circle3 = cmd.duplicate(circle1[0], ic=1)
cmd.setAttr(circle2[0] + '.rotateZ', 120)
cmd.setAttr(circle3[0] + '.rotateZ', -120)

allCurves = circle1[0], circle2[0], circle3[0]
cmd.select(allCurves)
cmd.makeIdentity(apply=True, t=1, r=1, s=1, n=0)

works great in Maya 2012, giving me this result:

enter image description here

Instead, in Maya 2015, the result of the same code is as follows:

enter image description here

All circles move to the origin.

The command seems to cmd.makeIdentitywork differently, but reading maya docs means the command is the same. Also, the parameters of the construction history are the same. I can’t understand what Maya does behind the lines.

Why do these lines of code work differently?

+4
source share
3 answers

​​, (2015) makeIdentity, // ( makeNurbCircle node), , transformGeometry . Maya 2012, . , , .

2012 ; 2015 : 2012 on the left;  2015 on the right

, - , , makeIdentity , , ; transformGeometry , ( xform).

, : ( , )

import maya.cmds as cmds


def makeIdentityCurvesWithSharedHistory(curves=[]):
    for curve in curves:
        curveShape = cmds.listRelatives(curve, shapes=True)[0]    
        makeCircle = cmds.listConnections(curveShape, type='makeNurbCircle')[0]
        transformation = cmds.xform(curve, q=True, matrix=True)    
        transformGeoNode = cmds.createNode('transformGeometry')
        cmds.setAttr('%s.transform' % transformGeoNode, transformation, type='matrix')
        cmds.connectAttr('%s.outputCurve' % makeCircle, '%s.inputGeometry' % transformGeoNode)
        cmds.connectAttr('%s.outputGeometry' % transformGeoNode, '%s.create' % curveShape, force=True)
        cmds.xform(curve, matrix=[1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0])


circle1 = cmd.circle(nr=(0, 0, 1), c=(0, -1.1, 0), ch=1)
circle2 = cmd.duplicate(circle1[0], ic=1)
circle3 = cmd.duplicate(circle1[0], ic=1)
cmd.setAttr(circle2[0] + '.rotateZ', 120)
cmd.setAttr(circle3[0] + '.rotateZ', -120)

allCurves = circle1[0], circle2[0], circle3[0]
makeIdentityCurvesWithSharedHistory(allCurves)

: enter image description here

: Maya; Maya 2015.

+2

makeIdentity , :

circle1 = cmds.circle(nr=(0, 0, 1), c=(0, -1.1, 0), ch=1)
circle2 = cmds.duplicate(circle1[0], ic=1)
circle3 = cmds.duplicate(circle1[0], ic=1)
cmds.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
cmds.setAttr(circle2[0] + '.rotateZ', 120)
cmds.setAttr(circle3[0] + '.rotateZ', -120)

, MakeIdentity , , ; (ic=True), , . , "transformGeometry" , .

, , , .

+1

The problem is duplication of input connections. There used to be a mistake. Probably ... not sure.

Work code:

import maya.cmds as cmd

circle1 = cmd.circle(nr=(0, 0, 1), c=(0, -1.1, 0), ch=1)
circle2 = cmd.duplicate(circle1[0], ic=0) #InputConnections=0
circle3 = cmd.duplicate(circle1[0], ic=0) #InputConnections=0
cmd.setAttr(circle2[0] + '.rotateZ', 120)
cmd.setAttr(circle3[0] + '.rotateZ', -120)

allCurves = circle1[0], circle2[0], circle3[0]
cmd.select(allCurves)
cmd.makeIdentity(apply=True, t=1, r=1, s=1, n=0)
0
source

All Articles