You’re doing some things that would be smart for a more complicated setup, but you should try to just get it working first with simpler connections.
So first, don’t worry about doing this in local space. Just plug the world matrices of your nodes into the aimMatrix.
Second, you’re missing a connection. You have to have a matrix that tells the aimMatrix node where you’re aiming from, and that’s the
.inputMatrix plug. Basically, with this setup you’ve gotta have an extra transform above the node that you want aimed.
A good simple setup would be:
from maya import cmds
aimTar = cmds.spaceLocator(name='AimTarget')
upTar = cmds.spaceLocator(name='UpTarget')
pos = cmds.spaceLocator(name='Position')
output = cmds.spaceLocator(name='AimedNode')
aimMat = cmds.createNode('aimMatrix')
cmds.setAttr(aimMat + '.secondaryMode', 1)
cmds.connectAttr(pos+ '.worldMatrix', aimMat + '.inputMatrix')
cmds.connectAttr(aimTar + '.worldMatrix', aimMat + '.primaryTargetMatrix')
cmds.connectAttr(upTar + '.worldMatrix', aimMat + '.secondaryTargetMatrix')
cmds.connectAttr(aimMat + '.outputMatrix', output + '.offsetParentMatrix')
Try starting from that and making it more complicated from there.
And since you asked, I absolutely LOVE all these new low-level toys that maya has been getting recently. Maya has needed this low level stuff forever. IMO In the past, so many of maya’s yearly improvements are either trying to lower startup friction or impress investors. But they’ve done precious little to make things easier for more knowledgeable technical users until recently.
With these matrix nodes I don’t have to continually compose/decompose matrices all over the place to do the cool stuff. And, especially for more complicated setups, I don’t have to have extra nodes/constraints all over the place. I can usually get away with a multiply or three, and a connection to the .opm.