Regular tick/simulation message?

eric
Contributor

Regular tick/simulation message?

eric
Contributor
Contributor

I'd like to write a script where a particular function gets called every N seconds...(I want to do a physics simulation using magnetic fields and I need regular updates to the field display)

Is there a way to register a function to be called on a regular basis?

Thanks!

Eric

 

0 Likes
Reply
398 Views
2 Replies
Replies (2)

ekinsb
Alumni
Alumni

There is not any functionality to set up an event at a specific time interval.  However, we are working on some more generic functionality that will allow you do to this.  We're testing it now and expect it to be available in January or February.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes

Anonymous
Not applicable

May be something like this, though not safe:

bool bThreadSemaphore = true;

DWORD WINAPI MyThread(_In_ LPVOID lpParameter)
{
    while (bThreadSemaphore)
    {
        ...
        Sleep(3000);
    }
    return(0);
}

extern "C" XI_EXPORT bool run(const char* context)
{
    int id;
    CreateThread(NULL, 100000, MyThread, NULL, 0, &id);
    return true;
}

extern "C" XI_EXPORT bool stop(const char* context)
{
    bThreadSemaphore = false;
    Sleep(4000);
    return true;
}

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/calling-api-from-thread-c/m-p/6553496

 

0 Likes