Not my best topic, but I have an example below, which I made some time back. I think you need to return the matrix that will be the input to the OnInverse.

# Returns Kinematic chain joint values based on the target (matrix)

def OnInverse(kinobj):

t2 = kinobj.Target

t2.rotateRelY(180)

solutions = []

for i in range(CONFIG_COUNT):

y = t2.P.Y

x = t2.P.X

z = t2.P.Z

rz = t2.WPR.Z

solutions.append( ( VC_SOLUTION_REACHABLE, GetMappedJoints( [y, x, z, rz] )))

kinobj.Solutions = solutions

return True

z = vcVector.new(0,0,1,0)

EPSILON = 0.00001

def OnCalculateTarget(fullMtx, baseMtx, toolMtx, isExternal):

if JS[3]:

#With orientation around Z

toolMtx.invert()

t6 = baseMtx*fullMtx*toolMtx

else:

# fixed orientation

toolMtx_inv = vcMatrix.new( toolMtx )

toolMtx_inv.invert()

toolMtx.rotateAbsY(180)

root2target = baseMtx*fullMtx

root2target.WPR = toolMtx.WPR

t6 = root2target*toolMtx_inv

return t6

###### Attachments:

You must be

logged in to view attached files.