Revolute Joint Motion Faster/Smoother via Animate than driven by Script

Revolute Joint Motion Faster/Smoother via Animate than driven by Script

RogerInHawaii
Collaborator Collaborator
1,193 Views
3 Replies
Message 1 of 4

Revolute Joint Motion Faster/Smoother via Animate than driven by Script

RogerInHawaii
Collaborator
Collaborator

I've got some Revolute joints. If I use the Animate option on the model the motion of the joint is really nice and smooth and fast...


But if I use a C++ Script to do the animation it's quite jerky and not nearly as fast...


The script that's driving the joint is basically this...

 

double Pi = 3.1415926535897;
double angle360DegreesInPiTerms = 2*Pi;
double angle180DegreesInPiTerms = Pi;
double angle90DegreesInPiTerms = Pi / 2;
double angle45DegreesInPiTerms = Pi / 4;
double angle1DegreeInPiTerms = 0.0174533;
double angle0DegreeInPiTerms = 0.0;

// Move joint UP 90 degrees (from initial 0 degrees)
for (double angle = 0.0 ; angle <= angle90DegreesInPiTerms; angle += angle1DegreeInPiTerms * 3)
{
	itsRevoluteJointMotion->rotationValue(angle);
	adsk::doEvents();
}
// Move joint down to -90 degrees
for (double angle = angle90DegreesInPiTerms; angle >= -angle90DegreesInPiTerms; angle -= angle1DegreeInPiTerms * 3)
{
	itsRevoluteJointMotion->rotationValue(angle);
	adsk::doEvents();
}
// Move joint back to 0 degrees
for (double angle = -angle90DegreesInPiTerms; angle <= 0.0 ; angle += angle1DegreeInPiTerms * 3)
{
	itsRevoluteJointMotion->rotationValue(angle);
	adsk::doEvents();
}

So why is the model-driven Animate so much faster and smoother than one driven by a C++ script? I tried several different "increments" in the for-loops and nothing makes it any better.

 

0 Likes
1,194 Views
3 Replies
Replies (3)
Message 2 of 4

RogerInHawaii
Collaborator
Collaborator

Could someone please address this issue?

 

I really need my script-driven animations to be just as fast as the built-in Joint "Animate" option.

 

0 Likes
Message 3 of 4

GillesJrBisson
Contributor
Contributor

Hi,

I am experiencing the exact same problem.

Did you find anything to explain and/or improve this issue ?

 

Has anybody else found anything ?

 

Regards !

 

0 Likes
Message 4 of 4

RogerInHawaii
Collaborator
Collaborator

It's been a long time since I worked on that particular project and that particular issue.

I do recall, once in a while, when I was much later working on a different project but also trying to manipulate components by means of a script, that if I was doing a lot of work on the script during one design/programming session, that the animation would seem to get slower and slower. But if I stopped working, shut down Fusion 350, turned the computer completely off, and came back to it later and then ran the script, it would work faster. I concluded that Fusion 360 was (maybe?) somehow getting bogged down, perhaps consuming lots and of lots of memory, maybe not freeing memory properly between sequential runs of the script, and that's what was causing the unacceptable slow-down of the animations.

So, you could give that a try. Just shut it down completely and restart the computer and restart Fusion 360 and get back into the project cleanly, then run the script again.

0 Likes