Request

Response

    Use OnDemand Inputs

    Once you have a running custom AppBundle with an Activity and a WorkItem, you can consider more advanced processing.

    This walkthrough will explain how you can optimize data downloads using so called onDemand inputs in Activities and WorkItems. This mechanism allows your AppBundle to ask for additional data to be downloaded using an http call during WorkItem processing only on an as-needed basis.

    Conceptually, onDemand inputs allow your AppBundle to access additional resources based on the actual run of a given WorkItem, using a url that can be parameterized to query exactly the data you need right now. It can either access additional specific design files on your storage, or call your own server’s http API to query for json data etc.

    There are several steps you need to take in order to be able to use onDemand inputs. First, when you are creating your activity, you must specify some of the input arguments as being onDemand. Note that onDemand can only be used when the parameter verb is get or head.

    Example

    curl -i -X POST \
      https://developer.api.autodesk.com/da/us-east/v3/activities
      ...
      -d '{
      "id": "MyActivity",
      ...
        "parameters": {
          "InventorDoc": {
            "verb": "get"
          },
          "OptionalIpt": {
            "verb": "get",
            "onDemand": true
          },
          ...
        }
      }
    
    Show More

    Second, you must refer to this parameter when sending the WorkItem, as shown here:

    Example

    curl -i -X POST \
      https://developer.api.autodesk.com/da/us-east/v3/workitems \
      ...
      -d '{
      "activityId": "MyActivity+prod",
      ...
      "arguments": {
        "InventorDoc": {
          "url": "https://s3-us-east-1.amazonaws.com/inventorio-prod/documentation/APIBasics/Box.ipt"
        },
        "OptionalIpt": {
          "url": "https://s3-us-east-1.amazonaws.com/inventorio-prod/documentation/APIBasics"
        }
      ...
      }
    }
    
    Show More

    Third, your AppBundle add-in has to be able to ask for the optional onDemand input. This is done via writing specially formatted text to the log trace. The required format is best documented in the following method that handles a request for such an optional input and waits for the http call result:

    Example

    private static bool GetOnDemandFile(string name, string suffix, string headers, string responseFile)
        {
            // writing a string (formatted according to ACESAPI format) to trace
            // invokes the onDemand call to get the desired optional input file
            LogTrace("!ACESAPI:acesHttpOperation({0},{1},{2},{3},{4})",
                name ?? "", suffix ?? "", headers ?? "", "", responseFile ?? "");
    
            // waiting for a control character indicating
            // that the download has successfully finished
            int idx = 0;
            while (true)
            {
                char ch = Convert.ToChar(Console.Read());
                // error
                if (ch == '\x3')
                {
                    return false;
                }
                // success
                else if (ch == '\n')
                {
                    return true;
                }
    
                // to many unexpected characters already read from console,
                // treating as other error / timeout
                if (idx >= 16)
                {
                    return false;
                }
                idx++;
            }
        }
    
    Show More

    An actual call to the function can be made like

    GetOnDemandFile("OptionalIpt", "optPart.ipt", "", $"file://optPart.ipt");
    

    function parameters

    NameDescription
    name name of the onDemand input parameter as specified in the Activity
    suffix a query string - optional parameters that can be addded to the url defined in the WorkItem
    headers http call headers
    responseFile tells the system the filename under which the onDemand file is saved by the http call, must start with “file://

    The tricky pieces here are:

    • the special beggining of the trace line (“!ACESAPI:acesHttpOperation”),
    • the way to identify that the http operation has finished (and how) - check the test of char read from console in the function code sample above.

    The method to support onDemand calls from an add-in is part of the Inventor Visual Studio template .

    A working example of onDemand input can also be found in the basic design.automation.inventor-csharp-basics sample referrenced in the previous walkthrough.

    Known issues:

    • when you use the parameter zip=’true’ with parameter onDemand=’true’ then a zip file will be downloaded, not unzipped.
     
    ______
    icon-svg-close-thick

    Cookie preferences

    Your privacy is important to us and so is an optimal experience. To help us customize information and build applications, we collect data about your use of this site.

    May we collect and use your data?

    Learn more about the Third Party Services we use and our Privacy Statement.

    Strictly necessary – required for our site to work and to provide services to you

    These cookies allow us to record your preferences or login information, respond to your requests or fulfill items in your shopping cart.

    Improve your experience – allows us to show you what is relevant to you

    These cookies enable us to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we use to deliver information and experiences tailored to you. If you do not allow these cookies, some or all of these services may not be available for you.

    Customize your advertising – permits us to offer targeted advertising to you

    These cookies collect data about you based on your activities and interests in order to show you relevant ads and to track effectiveness. By collecting this data, the ads you see will be more tailored to your interests. If you do not allow these cookies, you will experience less targeted advertising.

    icon-svg-close-thick

    THIRD PARTY SERVICES

    Learn more about the Third-Party Services we use in each category, and how we use the data we collect from you online.

    icon-svg-hide-thick

    icon-svg-show-thick

    Strictly necessary – required for our site to work and to provide services to you

    Qualtrics
    W
    Akamai mPulse
    W
    Digital River
    W
    Dynatrace
    W
    Khoros
    W
    Launch Darkly
    W
    New Relic
    W
    Salesforce Live Agent
    W
    Wistia
    W
    Tealium
    W
    Upsellit
    W
    CJ Affiliates
    W
    Commission Factory
    W
    Google Analytics (Strictly Necessary)
    W
    Typepad Stats
    W
    Geo Targetly
    W
    SpeedCurve
    W
    Qualified
    #

    icon-svg-hide-thick

    icon-svg-show-thick

    Improve your experience – allows us to show you what is relevant to you

    Google Optimize
    W
    ClickTale
    W
    OneSignal
    W
    Optimizely
    W
    Amplitude
    W
    Snowplow
    W
    UserVoice
    W
    Clearbit
    #
    YouTube
    #

    icon-svg-hide-thick

    icon-svg-show-thick

    Customize your advertising – permits us to offer targeted advertising to you

    Adobe Analytics
    W
    Google Analytics (Web Analytics)
    W
    AdWords
    W
    Marketo
    W
    Doubleclick
    W
    HubSpot
    W
    Twitter
    W
    Facebook
    W
    LinkedIn
    W
    Yahoo! Japan
    W
    Naver
    W
    Quantcast
    W
    Call Tracking
    W
    Wunderkind
    W
    ADC Media
    W
    AgrantSEM
    W
    Bidtellect
    W
    Bing
    W
    G2Crowd
    W
    NMPI Display
    W
    VK
    W
    Adobe Target
    W
    Google Analytics (Advertising)
    W
    Trendkite
    W
    Hotjar
    W
    6 Sense
    W
    Terminus
    W
    StackAdapt
    W
    The Trade Desk
    W
    RollWorks
    W

    Are you sure you want a less customized experience?

    We can access your data only if you select "yes" for the categories on the previous screen. This lets us tailor our marketing so that it's more relevant for you. You can change your settings at any time by visiting our privacy statement

    Your experience. Your choice.

    We care about your privacy. The data we collect helps us understand how you use our products, what information you might be interested in, and what we can improve to make your engagement with Autodesk more rewarding.

    May we collect and use your data to tailor your experience?

    Explore the benefits of a customized experience by managing your privacy settings for this site or visit our Privacy Statement to learn more about your options.