'absolute' coordinates?


(slikdigit) #1

hello. I’m new to python, so don’t blame me too much for asking the obvious.
I’m trying to automate the pistons on my spidermech for the challenge, and I’d rather use python with empties than armatures. what I can’t figure out is how to get the ‘actual’ location in world coords for an object that is moved via parenting or constraints? LocX, RotX seem to return the original coordinate; when I move the parent or the constraining object, they do not change (as does not the data when pressing Nkey in the 3d window)
Thanks
Bassam
PS: if this info shows up somewhere I haven’t looked, feel free to RTFM me; just point me to the right manual.


(eeshlo) #2

Use the matrix of the parented object, the location vector happens to be the easiest to figure out:


object = Blender.Object.Get(objectname)
mtx = object.matrix
LocXYZ = (mtx[3][0], mtx[3][1], mtx[3][2])


(slikdigit) #3

thanks!.
but what if the location of the parented object is driven (via an ik chain, for instance?)
I’ll test and see.
it seems that it still has the same prob.
the thing is, the piston is attached to a universal joint mounted to the leg. I can parent empties to the armature bones, and try to access via python their positions. But I can’t even get the rotations for the armatures via python (or can I?)
It’s possible that I can get the joint to work via constraints only. But even using the constraint system I have the same problem (I think- I could be just missing something)
I’ll have a go at using 2.25’s action constraints. But if anyone has a clue to getting this ‘actual’ position in a general case, I’d be (undersatement) ecstatic to here it.
Once again, thanks eeshlo; its something I hadn’t thought of and might be useful in the future.
Bassam


(theeth) #4

Why don’t you use the Tracking trick to make the piston work? Just make each part of the piston track the other part.

Martin


(slikdigit) #5

yes- that part works, but its not the problem.
the problem is that the piston (its actually a hydraulic cylinder, but it looks like a piston) connects to the body of the mech, and to the leg via universal joints (not ball-socket joints). To convicingly animate the joint I have to isolate the local X and Z rotations of the joints (or was that Y? I’m away from the comp that has the project). Isolating these rotations is proving to be the challenge; I may go to ball socket joints (though they do not look as cool) If I cannot find the solution. Alternately, I might try to ‘cheat’ the univ joint so it spins on an axis, and the Xrot component is never needing to move.
I’d rather figure out how to get it working properly.
suggestions?