Callbacks
The Fusion engine uses a different approach to callbacks than other engines. Instead of the standard callback mechanism, Fusion provides specialized methods in the “adsk” namespace that work with TypeScript to handle callback functionality. This approach is designed to integrate seamlessly with Fusion’s TypeScript-based API.
For information about callbacks for other engines, see the standard callback mechanism documentation.
OnProgress
To send a message to the URL defined in the OnProgress property in the WorkItem you can use the following code:
result = adsk.OnProgress("Progress message");
The following JSON will be sent to the URL defined in the WorkItem:
{
"id": "taskID",
"progress": "Progress message"
}
The result of the function is an integer that represents the status of the request. If the request was successful the result will be 200.
OnDemand
To download a file that is defined as OnDemand in the Activity you can use the following code:
result, message = adsk.getOnDemandFile("filename", "suffix", "headers", "responseFile")
Parameters:
| Parameter | Type | Description |
|---|---|---|
| filename | String | Filename of the OnDemand input parameter as specified in the Activity |
| suffix | String | Optional query string parameters to append to the URL defined in the WorkItem |
| headers | String | HTTP call headers |
| responseFile | String | The filename for saving the downloaded OnDemand file |
The result of the function is an integer that represents the status of the request. If the request was successful the result will be 200. If the integer is -1 the request failed without being able to send a message to the URL defined in the WorkItem. In any case the message will contain more information about the error.