- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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 #
Solved! Go to Solution.