Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

blendShape errors

blendShape errors

jwlove
Advocate Advocate
2,897 Views
10 Replies
Message 1 of 11

blendShape errors

jwlove
Advocate
Advocate

This is related to another blendShape post I made here: calculate blendshape inputTargetItem indices for negative inbetweens

 

feel free to read that for some more info... but a short recap, here's some code to create a cube with a target that has 2 in-betweens (one at 10 and one at -10) which is directly driven by an attribute on a circle.

 

 

import maya.cmds as mc

# create base and 'control'
#
base = mc.polyCube(n='base', ch=False)[0]
ctrl = mc.circle(n='ctrl', nr=(0,1,0), ch=False)[0]
mc.addAttr(ctrl, ln='test', at='float', k=True)

# create targets
#
pos10_tgt = mc.polyCube(n='pos10_tgt', ch=False)[0]
neg10_tgt = mc.polyCube(n='neg10_tgt', ch=False)[0]
mc.xform(pos10_tgt, ws=True, t=(1.5, 0, 0))
mc.xform(neg10_tgt, ws=True, t=(3.0, 0, 0))
mc.move(0, 1, 0, '%s.cp[2:5]' %pos10_tgt, r=True)
mc.move(0, -1, 0, ['%s.cp[0:1]' %neg10_tgt, '%s.cp[6:7]' %neg10_tgt], r=True)

# create blendShape
#
bs = mc.blendShape(base, n='test_bs')[0]
mc.setAttr('%s.supportNegativeWeights' %bs, 1)
mc.blendShape(bs, e=True, t=(base, 0, pos10_tgt, 10.0))
mc.blendShape(bs, e=True, t=(base, 0, neg10_tgt, -10.0))

# alias attr and connect it
#
mc.aliasAttr('test', '%s.weight[0]' %bs)
mc.connectAttr('%s.test' %ctrl, '%s.test' %bs)

The error that's giving me trouble right now is if I try to disconnect the -10 inbetween target.  I've tried to disconnect it in the node editor and with disconnectAttr, but I get an error....  Here's some code to demonstrate the error:

 

conns = mc.listConnections('%s.inputTarget' %bs, p=True, c=True)

for i in xrange(0, len(conns), 2):
    mc.disconnectAttr(conns[i+1], conns[i])

# another option
#
for i in xrange(0, len(conns), 2):
    mc.disconnectAttr('%s[0]' %conns[i+1], conns[i])

the error says that the destination plug 'neg10_tgt.worldMesh[0]' doesn't exist (which it does....).  It seems like maya can't fully handle the negative index inputTarget plug.

 

Is there a way to disconnect the attr without supplying source and destination plugs?  If so, I could try it and see if it gets around the issue...

 

The only thing that seems to work is to delete the target, but I'm trying to do this programmatically while retaining the target for situations where I'm adding a tangent space target and need to disconnect it to actually get the target to update...

 

 

 

Here are some errors I noticed that I mentioned in that other post (adding here since I'm not sure if someone from Autodesk noticed since I answered my own question....):

 

 

- The weight attr does not show up in the channel box for the blendShape until it's connected - not a huge deal since I'm doing this with code and it still works, but I thought it was worth mentioning since it may be a bug... (btw - it does show up if I add a target with a target value of 1).
 
- If I have the input/output connections of the blendShape pulled up in the node editor and mouse over the circle/dot in front of the negative inbetween's inputGeomTarget attr, maya spits out this error: // Error: line 1: No object matches name: test_bs.inputTarget[0].inputTargetGroup[0].inputTargetItem[-2147478650] //.
 
- Also, I can list connections from the target world mesh attr and get the corresponding inputGeomTarget on the blendShape, but if I list connections from the inputGeomTarget for the negative target I get an error:

 

pos_igt = mc.listConnections('%s.worldMesh[0]' %pos10_tgt, p=True)[0]
neg_igt = mc.listConnections('%s.worldMesh[0]' %neg10_tgt, p=True)[0]

pos_igt  # Result: u'test_bs.inputTarget[0].inputTargetGroup[0].inputTargetItem[15000].inputGeomTarget' #
neg_igt  # Result: u'test_bs.inputTarget[0].inputTargetGroup[0].inputTargetItem[-2147478650].inputGeomTarget' #

mc.listConnections(pos_igt)  # Result: [u'pos10_tgt'] #
mc.listConnections(neg_igt)  # ValueError: No object matches name: test_bs.inputTarget[0].inputTargetGroup[0].inputTargetItem[-2147478650].inputGeomTarget #
0 Likes
Accepted solutions (3)
2,898 Views
10 Replies
Replies (10)
Message 2 of 11

jwlove
Advocate
Advocate

Thought I should note this (thought I had put it in the previous post, but apparently didn't):

 

The error saying that the destination plug 'neg10_tgt.worldMesh[0]' doesn't exist is odd to me since that's actually the source plug (and it does exist)... the destination plug is the negative index inputTargetItem attr.  The positive index inputTargetItem plug disconnects properly, so I know I didn't make a mistake in the for loop logic...

 

Here's the exact errors the disconnect for loops spit out:

 

# RuntimeError: The destination attribute 'neg10_tgtShape.worldMesh' cannot be found. #

# RuntimeError: The destination attribute 'neg10_tgtShape.worldMesh[0]' cannot be found. #
0 Likes
Message 3 of 11

jwlove
Advocate
Advocate
Accepted solution

Well, I've managed to figure out something to disconnect the attrs...  I had to jump through some annoying hoops via tha api, but it wasn't too terrible.  In the process, I ran across another error:

 

import maya.api.OpenMaya as om

selList = om.MSelectionList()
selList.add('test_bs.inputTarget[0].inputTargetGroup[0].inputTargetItem[-2147478650].inputGeomTarget')

dst_plug = selList.getPlug(0)

This errors when trying to add the plug to the selection list:

 

# RuntimeError: (kInvalidParameter): Object does not exist #

It actually does exist.

 

Anyway... I'll post the code I put together to get this to work, but I'd like to get a response from an Autodesk representative before I do.  I'm hoping all of this can get added to their bug list, and I think having an accepted solution will keep them from even reading the posts.  Somehow this thread got "escalated" - I don't know how or by whom, but thanks to whomever did it!

0 Likes
Message 4 of 11

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

I've confirmed with our engineers that Maya doesn't support negative indices. The only negative index Maya could have is -1 which is invalid. I am sorry that our support hasn't reached you in time. 

 

Yours,

Li

0 Likes
Message 5 of 11

jwlove
Advocate
Advocate
Accepted solution

Thank you for the response Li.  I assumed maya didn't support negative indices too, but, I am confused - when you use supportNegativeWeights for blendShapes to be able to add inbetweens at values less than -5 (-5 works out to index 0), then you do get indices that are negative; in fact they're extremely small negative numbers -2 billion +!

 

You can see this in the code snippet at the bottom of the first post in this thread where I list connections of the -10 inbetween target - which returns 'test_bs.inputTarget[0].inputTargetGroup[0].inputTargetItem[-2147478650].inputGeomTarget'

 

So, maya.cmds functions and even api classes (like listConnections, connectAttr, disconnectAttr, adding to MSelectionList, etc) on these negative index blendShape plugs fails.

 

For anyone following this, here's the actual code I got to work - had to use MFnDependencyNode.findPlug and traverse down the multi attrs to get to the right one (that's the hoops I mentioned):

 

import maya.api.OpenMaya as om

selList = om.MSelectionList()
selList.add(bs)  # bs is stored from the code generating the blendShape

dependFn = om.MFnDependencyNode(selList.getDependNode(0))
dgMod = om.MDGModifier()

iti_plug = dependFn.findPlug('inputTarget', True).elementByLogicalIndex(0).child(0).elementByLogicalIndex(0).child(0)
ib_indices = iti_plug.getExistingArrayAttributeIndices()

for ib_index in ib_indices:
    dst_plug = iti_plug.elementByLogicalIndex(ib_index).child(0)
    src_plug = dst_plug.source()
    print('-----')
    print('src', src_plug.name())
    print('dst', dst_plug.name())
    dgMod.disconnect(src_plug, dst_plug)

dgMod.doIt()

The print statements are really only there to show what plugs are being disconnected - and to show they actually exist and are viable... it would error otherwise...  This does what the simple disconnectAttr for loops from the first post in this thread were trying to do.  It works, but there's no undo, of course.

 

do blendShapes need some extra support for the negative indices for "regular" maya commands?

 

 

0 Likes
Message 6 of 11

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I found there is a similar issue in our system. They said they've found an acceptable solution and I am asking our development team about this. I'll get you back when I've heard something.

 

Yours,

Li

0 Likes
Message 7 of 11

jwlove
Advocate
Advocate

thanks Li - looking forward to hearing back from you on this!

 

I've provided about 3 or 4 reproduceable errors for the dev team in this thread if that helps them at all.  If an update to fix this is coming, would it be only for Maya 2018 and beyond, or would there be an update for prior versions too (I'm currently working in Maya 2017)?

 

feel free to answer this once you hear back from the engineers - I know you're pretty busy!

 

thanks again!

0 Likes
Message 8 of 11

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I think it should be only available for Maya 2018 or above. A future update for Maya 2017 may be coming soon, so no guarantees.

 

Yours,

Li

0 Likes
Message 9 of 11

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I've got a reply for engineers, they considered this is a defect.

 

Yours,

Li

0 Likes
Message 10 of 11

jwlove
Advocate
Advocate

I don't quite understand... did they explain any further?  It's a defect in what way?

 

Do they mean it's a defect in that you shouldn't be able to make the negative index inbetween in the first place?

 

Or do they mean that the commands and related bugs I mentioned in this thread should actually work, and the errors they give are the defect?

 

Thanks for looking into this - I appreciate any additional clarity you can find out.

0 Likes
Message 11 of 11

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

We are still discussing about the details. Engineers suggest that listConnection not supporting negative index is an issue. But there are several other commands won't work with negative index either, so it is still in discussion. 

 

 

Yours,

Li

0 Likes