-
Re: How to get information from an Animation with MotionStudyResult GetLinearVelocity
Hans Björk Jul 26, 2017 7:01 AM (in response to Hans Björk)I can add some neater psuedo-code if it help understand what I'm trying to do:
hRes = pModExt->GetMotionStudyManager( & pReturnObj ); CComPtr<IMotionStudyManager> pMotStuMgr;
hRes = pReturnObj->QueryInterface( __uuidof(IMotionStudyManager), (void**) &pMotStuMgr );
hRes = pMotStuMgr->GetMotionStudyNames( & vStudyNames );
for( bsName in vStudyNames )
CComPtr<IMotionStudy> pMotionStudy = NULL; hRes = pMotStuMgr->GetMotionStudy( bsName, & pMotionStudy ); hRes = pMotionStudy->GetDuration( & dDuration ); // This is correct, accessing the animation works! hRes = pMotionStudy->Activate( & vbRet ); hRes = pMotionStudy->Calculate( & vbRet ); CComPtr<IMotionStudyResults> pResults = NULL; hRes = pMotionStudy->GetResults( swMotionStudyTypeAssembly, & pResults ); // Get the result for this Animation. hRes = pResults->IsOutOfDate( & vbIsOutOfDate ); // returns not out of date // Get components in the model... hRes = pRootComp->GetChildren( & vChildren ); for( CComPtr<IComponent2> pComp in vChildren ) for( double dIter=0.0; dIter <= dDuration+0.001; dIter += 0.1 )
hRes = pResults->GetLinearVelocity( dIter, pComp, &pReturnVV ); // Is this the correct component? hRes = pVelocityV->get_IArrayData( & oaVelocity ); Result: x == y == z == 0.0? Always, for all times and components, even out of bounds times The same for GetAngularVelocity() and GetCMPosition -
Re: How to get information from an Animation with MotionStudyResult GetLinearVelocity
Hans Björk Jul 27, 2017 4:53 AM (in response to Hans Björk)With a bit of experimenting I have found that only Motion Studies of type Motion Analysis return any values, but the same values for any value of time, regardless of how the components move. GetLinearVelocity, GetLinearAcceleration and GetCMPosition returns the same vector for all values of argument Time.
And if I ask for a IMotionStudyResult of type swMotionStudyTypeCosmosMotion from an IMotionStudy of type swMotionStudyTypeAssembly and then call GetLinearVelocity, SolidWorks crashes on the GetLinearVelocity call.
Obviously IMotionStudyResult does not even remotely work the way I had imagined after reading the documentation.
-