Hello! I believe your method is working properly, however, it looks like 
there are some local rotate pivots on the control you are querying the 
worldMatrix from, that are making the world matrix appear to be in the 
incorrect location. If you place a locator under the "C_big_vine_mid_ctrl" 
and zero it out, you will see the offset.

In this case, instead of running the getAttr on the control itself, you 
should be able to get the worldMatrix of the 'C_big_vine_mid_DrvJ' joint 
that is parented under the control instead. That joint seems to have the 
proper translation values to compensate for the offset, and should return 
the proper world translate values of the controller location.

Hope that does the trick, though I'm sure there are probably a bunch of 
different ways to return a worldMatrix that takes local rotation pivots 
into account.

On Saturday, November 6, 2021 at 3:06:29 PM UTC-7 kiri...@gmail.com wrote:

> Hello, animator here. I really can't figure out this problem for several 
> weeks so hopefully someone can help me. 
>
> I am trying to get a worldMatrix of a controller at different frames 
> WITHOUT moving in the timeline. I am using getAttr() with the time argument 
> but it gives me wrong result on some specific controllers. I am not good 
> enough in rigging to understand what is so specific about these controllers.
>
> Here is my code where I compare the matrices translations of a single 
> selection, obtained by different method. xform(ws = True) that gives me 
> always the correct result. And Funny enough, getAttr() without the time 
> argument give me the correct result as well. Why on earth just adding the 
> time argument make the result all wrong? 
>
> import maya.cmds as mc
> import random
>
> #Get selection
> ctrl = mc.ls(sl=True)[0]
>
> #Get a random frame 
> frameNr = random.randint(1,100)
> #Set the current time to test xform 
> mc.currentTime(frameNr)
>
> print ('Frame: %s'%mc.currentTime(q=True))
>
> #Get the matrix with getAttr with the Time argument - bad result
> getAttr_matrix_time = mc.getAttr('%s.worldMatrix[0]'%ctrl, time = frameNr)
> print 
> (getAttr_matrix_time[12],getAttr_matrix_time[13],getAttr_matrix_time[14], ' 
> -> getAttr(time) ')
>
> #Get the matrix with getAttr without the time argument - good result 
> getAttr_matrix = mc.getAttr('%s.worldMatrix[0]'%ctrl)
> print (getAttr_matrix[12],getAttr_matrix[13],getAttr_matrix[14], ' -> 
> getAttr() ')
>
> #Get the matrix with xform - good result 
> xform_mat = mc.xform(ctrl , matrix = True, q = True, ws = True)
> print (xform_mat[12],xform_mat[13],xform_mat[14], ' -> xform() ')
>
>
> My bug comes on this rig free rig for example: 
> https://agora.community/content/bulbasaur
> On the controller "C_big_vine_mid_ctrl". 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/116ddb55-73d8-4b81-b0d4-e3cd84585c88n%40googlegroups.com.

Reply via email to