Same python code works differently on differently Maya (2012 - 2015) -
this simple code
import maya.cmds 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 in maya 2012, giving me result:
instead, in maya 2015 result of same code this:
all circles moves origin.
it seems command cmd.makeidentity
work differently, reading maya docs command same. construction history settings same. can't understand maya behind lines.
why lines of code works differently?
the real problem because of probable bug in way new maya (2015) performing preparations makeidentity
when nodes have shared history/connections/nodes (in case makenurbcircle
node). seems creating interim transformgeometry
nodes compensate to-be frozen transforms in wrong order in chain. wasn't case in maya 2012, when order seems right. if @ comparison below, you'll see why.
2012 on left; 2015 on right:
either ways, if want preserve shared history , freeze transform way whatever reason, might have manually makeidentity
attempts to, in cleaner way want to; i.e. connect transformgeometry
nodes in right order before manually freezing transformations on transforms (using xform
).
here whipped that: (i update answer comments , explanation when find time later)
import maya.cmds cmds def makeidentitycurveswithsharedhistory(curves=[]): 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)
if above code used:
disclaimer: theoretically, should work in version of maya; have tested on maya 2015.
Comments
Post a Comment