Request

Response

    Arguments

    The Automation API supports three well-known arguments for activities that use any Autodesk.Fusion-engine. If an argument of a Fusion-activity has the name (and type) of any of they following arguments, they will be treated in a special way.

    Any activity can define a TaskScript, TaskScriptUrl and an AppBundle, but only one of them will be executed.

    The AppBundle takes precedence over the TaskScriptUrl, which takes precedence over the TaskScript.

    The well-known arguments are:

    1. TaskScript

    If you have a small script you can use the well-known argument TaskScript to define it inline instead of in an AppBundle. For example:

    {
            "arguments":{
                    "TaskScript":"import { adsk } from \"@adsk/fas\"; adsk.log(\"Hello Fusion\");"
            }
    }
    

    To use the well-known argument TaskScript, introduce the following argument when posting an activity:

    {
    ...
            "parameters": {
                    "TaskScript": {
                            "verb": "read",
                            "description": "the script to run",
                            "required": true
                    },
            },
    ...
    }
    
    Show More

    2. TaskScriptUrl

    If you have a large script you can use the well-known argument TaskScriptUrl to define a URL from which to download the script before executing the workitem. Again, this is an alternative to storing the code in the AppBundle. For example:

    {
            "TaskScriptUrl":{
                    "url":"https://<YOUR_SERVER_URL>/script/sample.ts",
                    "headers":{
                            "Authorization":"Bearer <YOUR_ACCESS_TOKEN>"
                    }
            }
    }
    
    Show More

    The header is optional and can be used to pass a token to the server

    To use the well-known argument TaskScriptUrl, introduce the following argument when posting an activity:

    {
    ...
            "parameters": {
                    "TaskScriptUrl": {
                            "verb": "get",
                            "description": "the script to download and run",
                            "required": true
                    },
            },
    ...
    }
    
    Show More

    3. TaskParameters

    This well-known argument TaskParameters is used to pass arguments dynamically to the script either as a string or as a json object. For example

    {
            "TaskParameters":"{\n  \"fileURN\": \"urn:adsk.wipprod:dm.lineage:shuH8zKvThW_4Tdu-m22sw\",\n  \"parameters\": {\n    \"d3\": \"40mm\"\n  }\n}"
    }
    

    Equivalently, you can submit a JSON object as a DirectValueParameter

    {
    "TaskParameters": {
            "value": {
                    "fileURN": "urn:adsk.wipprod:dm.lineage:shuH8zKvThW_4Tdu-m22sw",
                    "parameters": {
                            "d3": "40mm"
                    }
            }
    }
    
    Show More

    Either way you can read out the value of the TaskParameters in the TypeScript-code by using adsk.parameters as a string: {"fileURN":"urn:adsk.wipprod:dm.lineage:shuH8zKvThW_4Tdu-m22sw","parameters":{"d3":"40mm"}}. Optionally, if the adsk.parameters are a stringified JSON object, you can turn the string into a JSON object by using JSON.parse(adsk.parameters).

    To use the well-known argument TaskParameters, introduce the following argument when posting an activity:

    {
    ...
            "parameters": {
                    "TaskParameters": {
                            "verb": "read",
                            "description": "the parameters for the script",
                            "required": false
                    },
            },
    ...
    }
    
    Show More