how to acquire the component position at specific time from motion study result?

34 Views Asked by At

I am facing the problem to get position of a component at specific time from motion study result. There is only GetCMPosition method in the API, which is the center of mass, not the origin point of the component. So do I need to calculate it by myself? But I do think there is a better way to acquire it.

1

There are 1 best solutions below

0
On

After several hours I found a solution myself... post pseudo code here and hope it could help someone.

public static ActionResult ExtractAnimation(this MotionStudy ms)
{
    if (!ms.Activate())
        return ActionResult.Error("activate motion study failed!");
    double duration = ms.GetDuration(); // in seconds

    if (duration <= 0) return ActionResult.Error("error message");

    for (double currentTime = 0; currentTime < duration; currentTime += AnimationStepSize)
    {
        ms.SetTime(currentTime);
        MethodUsingTransform(component.Transform2, currentTime);
    }

    ms.SetTime(duration);
    MethodUsingTransform(component.Transform2, duration);

    ms.Stop();
    return ActionResult.Success();
}