PyMel odd setMatrix() behavior on unconnected Transform nodes

PyMel odd setMatrix() behavior on unconnected Transform nodes

Anonymous
Not applicable
453 Views
0 Replies
Message 1 of 1

PyMel odd setMatrix() behavior on unconnected Transform nodes

Anonymous
Not applicable
I started the original question at http://t.co/ork5w8a2, but was told to also post this here:

Has anyone else experienced the following odd behavior with the pymel.core.nodetypes.Transform.setMatrix() method? It seems to me that if a node has zero input/output connections, and you augment the matrix attribute, the node will not properly redraw until Maya refreshes the viewport. This feels like a bug to me..

Take the following code:

import pymel.core as pm
import random


# start in a clean workspace
pm.system.newFile(force=True)

# ------------------------------------------------------
# From here on out, execute one line at a time in the
# script editor (highlight line -> ctl + enter)
#
# *** Do not move or click in the viewport until all
# code has been executed ***
# ------------------------------------------------------

# Create two transforms, one as source the other as target
src=pm.spaceLocator(name='sourceNode')
tgt = pm.createNode('joint', name='targetNode', parent=None)

# define the attrs to adjust
attrs =

# randomly relocate the source object (execute this entire block together)
for attr in attrs:
a = '%s.%s' % (tgt, attr)
pm.setAttr(a, random.randrange(0, 10, 1))

# frame our nodes
pm.viewFit()

# grab the new world matrix of our source object
wMatrix = tgt.getMatrix(worldSpace=True)

# set our source node to align to the target
src.setMatrix(wMatrix, worldSpace=True)

# Our 'repositioned' object still draws at the origin
# Querying the newly set matrix does not return identity (meaning it's been set)
print src.getMatrix(worldSpace=True)

# Seems like the setMatrix command isn't forcing re-evalation..
pm.refresh()

# delete sourceNode and target node and:
# - repeat same code line by line, clicking in the viewport instead of refreshing
# - repeat same code executing all but refresh command at once


I would expect the same behavior as calling, say:

# set a single 'standard' attribute
src.translateY.set(10)

# notice the viewport redraws to reflect attribute change


-csa
0 Likes
454 Views
0 Replies
Replies (0)