I’m wondering if anyone can (or would be willing to…) help me with a problem…
I’m trying to take locators from an FBX file, from a Vicon mocap system and then use the distance tool to measure the distance between two locators. The trick is, I’d like to export in some kind of csv format the following data from the distance tool for a whole sequence.
yes that’s doable, and I think the distance tool approach is only viable if you only care about a few distances.
For n times, you would more likely only calculate the world distance by measuring the length of the vector resulting of the substracting of both transform world locations.
I’d advise using a python script, that you could do yourself if you get a tad into it, there are a lot of references and the logic can be quite close from the Maya MEL.
The steps would be :
- beginning at a specific start frame / Set the timeline
and then a for loop with :
- get distance(s)
- store or write line directly
- proceed to next frame
two approach for writing the file :
line by line, in a csv format ( file.writeline )
storing all data in memory ( can be large depending on number of frame … ) and then writing at the end
i’d advise looking at using python dictionaries, and custom data format like json ( writes to file using json.dump i think )
I know those are only concepts, and if you don’t script it’ll be a bit blurry,
but that’s how I’d do it.
Keep in mind that the text data file formatting you choose will have to be readable easily by script on the other end.
you can use my friends ( Hashem Al SHaer ) technique .. he make tutorial for CMIVFX for this tip
we use this technique for many productions >
this is the link >>
It’s rather simple if you know a little of coding. I didn’t write the writing it down to a file part because I don’t work with that everyday so I haven’t memorized it. You could research it by yourself, or just copy and paste the log result into a txt file
In Python (pymel):
import pymel.core as pm
import math
# Variables
loc1 = pm.PyNode('locator1')
loc2 = pm.PyNode('locator2')
firstFrame = 0
lastFrame = 10
# Get Current Frame
curTime = pm.currentTime(q=1)
# Iterate Frames
for frame in range(int(firstFrame), int(lastFrame) + 1):
pm.currentTime(frame)
A = loc1.getTranslation(space='world')
B = loc2.getTranslation(space='world')
dis = abs(math.sqrt(math.pow(B[0]-A[0],2) + math.pow(B[1]-A[1],2) + math.pow(B[2]-A[2],2)))
print 'frame number: %s, %s, %s, %s' % (frame, loc1, loc2, dis)
# Go Back to current frame
pm.currentTime(curTime)