Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setAttr on floatArray data type does not work as expected #421

Open
ParticlePeter opened this issue Mar 28, 2019 · 0 comments
Open

setAttr on floatArray data type does not work as expected #421

ParticlePeter opened this issue Mar 28, 2019 · 0 comments

Comments

@ParticlePeter
Copy link

ParticlePeter commented Mar 28, 2019

When using setAttr on a floatArray data type attribute, the attribute data gets "corrupted". See example bellow: A 3 element floatArray created and initialized through maya.cmds, returns only one element (the first) after updated through PyMel. Resetting the attribute through maya.cmds.setAttr "un-corrupts" the attribute data again, but this is not shown in the example to keep it brief.
Seems to be a rarely used corner case, as setAttr on doubleArray data type works just fine.
Maya version 20180400, PyMel version 1.0.10.

import maya.cmds as mc
import pymel.core as pm

mc.createNode( 'locator', n='node' )
mc.addAttr(ln='dArray', sn='da', dt='doubleArray')
mc.addAttr(ln='fArray', sn='fa', dt='floatArray')

print 'mc.setAttr type doubleArray'
mc.setAttr("node.dArray", (2, 3.14159, 2.782), type="doubleArray")
print 'mc.getAttr : {0}'.format(mc.getAttr("node.dArray"))
print 'pm.getAttr : {0}'.format(pm.getAttr("node.dArray"))
print

print 'mc.setAttr type floatArray'
mc.setAttr("node.fArray", (2, 3.14159, 2.782), type="floatArray")
print 'mc.getAttr : {0}'.format(mc.getAttr("node.fArray"))
print 'pm.getAttr : {0}'.format(pm.getAttr("node.fArray"))
print

print 'pm.setAttr type doubleArray'
pm.setAttr("node.dArray", (1.0, 2.0, 3.0), type="doubleArray")
print 'mc.getAttr : {0}'.format(mc.getAttr("node.dArray"))
print 'pm.getAttr : {0}'.format(pm.getAttr("node.dArray"))
print

print 'pm.setAttr type floatArray'
pm.setAttr("node.fArray", (1.0, 2.0, 3.0), type="floatArray")
print 'mc.getAttr : {0}'.format(mc.getAttr("node.fArray"))    # Returns a list with one element
print 'pm.getAttr : {0}'.format(pm.getAttr("node.fArray"))    # Returns a list with one element
print
@ParticlePeter ParticlePeter changed the title setAttr on floatArray data type setAttr on floatArray data type does not work as expected Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant