Skip to content

Latest commit

 

History

History
144 lines (105 loc) · 7.11 KB

File metadata and controls

144 lines (105 loc) · 7.11 KB

Create App, Define Activity, Call the WorkItem

Description

Insomnia.REST workflow to create App, define activity, and call the WorkItem.

Setup

Before start with Design Automaiton workflow, I strongly recommend you to read throught all the details at Design Automation for Revit Documenation, and check the following steps if you already have basic understanding.

  1. Download or update Insomnia.REST from here.

  2. Create a Forge App. If you have already created a Forge App then you can skip this and proceed to the next step.

  3. From your local clone of the repository, import our Insomnia data Sketchit-App_Insomnia into the Insomnia REST application. You can find more details about it here

thumbnail

  1. After the import to Insomnia, we can see there is a predefined Enviorment called SketchIt-RevitIO-Env which will need your input for the variable values (client ID, client Secret...) This will make the process smoother and faster to use. You can find more details about it here

thumbnail

  1. Select the environment and enter your Forge App's Client ID and Client Secret. This is used for authentication. In the environment variables give your app an easy to manage unique nickname.

  2. Compile and package the sample applications as noted here. You will need this to upload the app to Design Automation. Alternatively you may also download the packages from SketchIt.zip.

  3. Create a nickname for your Forge App.

  4. Publish your Design Automation appbundle.

Create an appbundle zip package from the build outputs and publish the appbundle to Design Automation.

The JSON in your appbundle POST should look like this:

{
  "id": "SketchItApp",
  "engine": "Autodesk.Revit+2019",
  "description": "SketchIt appbundle based on Revit 2019"
}

Notes:

  • engine = Autodesk.Revit+2019 - A list of engine versions can be found here.

After you upload the appbundle zip package, you should create an alias for this appbundle. The JSON in the POST should look like this:

{
  "version": 1,
  "id": "test"
}

The instructions for these steps and more about appbundle are here.

  1. Publish your Design Automation activity.

Define an activity to run against the appbundle.

The JSON that accompanies the activity POST will look like this:

{
   "id": "SketchItActivity",
   "commandLine": [ "$(engine.path)\\\\revitcoreconsole.exe /al $(appbundles[SketchItApp].path)" ],
   "parameters": {
      "sketchItInput": {
         "zip": false,
         "ondemand": false,
         "verb": "get",
         "description": "SketchIt input parameters",
         "required": true,
         "localName": "SketchItInput.json"
      },
      "result": {
         "zip": false,
         "ondemand": false,
         "verb": "put",
         "description": "Results",
         "required": true,
         "localName": "sketchIt.rvt"
      }
   },
   "engine": "Autodesk.Revit+2019",
   "appbundles": [ "YourNickname.SketchItApp+test" ],
   "description": "Creates walls and floors from an input JSON file."
}

Notes:

  • engine = Autodesk.Revit+2019 - A list of engine versions can be found here.
  • YourNickname - The owner of appbundle SketchItApp. More information can be found here.

Then you should create an alias for this activity. The JSON in the POST should look like this:

{
  "version": 1,
  "id": "test"
}

The instructions for these steps and more about activity are here.

  1. Prepare your input and output url.

  2. Post your Design Automation workitem.

Now POST a workitem against the activity to run a job on your appbundle.

The JSON that accompanies the workitem POST will look like this:

{
  "activityId": "YourNickname.SketchItActivity+test",
  "arguments": {
    "sketchItInput": {
      "url": "data:application/json,{ 'walls': [ {'start': { 'x': -100, 'y': 100, 'z': 0.0}, 'end': { 'x': 100, 'y': 100, 'z': 0.0}}, {'start': { 'x': -100, 'y': 100, 'z': 0.0}, 'end': { 'x': 100, 'y': 100, 'z': 0.0}}, {'start': { 'x': 100, 'y': 100, 'z': 0.0}, 'end': { 'x': 100, 'y': -100, 'z': 0.0}}, {'start': { 'x': 100, 'y': -100, 'z': 0.0}, 'end': { 'x': -100, 'y': -100, 'z': 0.0}}, {'start': { 'x': -100, 'y': -100, 'z': 0.0}, 'end': { 'x': -100, 'y': 100, 'z': 0.0}}, {'start': { 'x': -500, 'y': -300, 'z': 0.0}, 'end': { 'x': -300, 'y': -300, 'z': 0.0}}, {'start': { 'x': -300, 'y': -300, 'z': 0.0}, 'end': { 'x': -300, 'y': -500, 'z': 0.0}}, {'start': { 'x': -300, 'y': -500, 'z': 0.0}, 'end': { 'x': -500, 'y': -500, 'z': 0.0}}, {'start': { 'x': -500, 'y': -500, 'z': 0.0}, 'end': { 'x': -500, 'y': -300, 'z': 0.0}}],'floors' : [ [{'x': -100, 'y': 100, 'z':0.0}, {'x': 100, 'y': 100, 'z': 0.0}, {'x': 100, 'y': -100, 'z': 0.0}, {'x': -100, 'y': -100, 'z': 0.0}], [{'x': -500, 'y': -300, 'z':0.0}, {'x': -300, 'y': -300, 'z': 0.0}, {'x': -300, 'y': -500, 'z': 0.0}, {'x': -500, 'y': -500, 'z': 0.0}] ]}"
    },
    "result": {
      "verb": "put",
      "url": "https://myWebsite/signed/url/to/sketchIt.rvt"
    }
  }
}

Notes:

  • YourNickname - The owner of activity SketchItActivity. More information can be found here.

The instructions for this step and more about workitem are here.

Usage

These Insomnia samples will allow you to easily issue REST API calls without using cumbersome cURL commands.

Note that you will have to carefully read through the requests - DELETE-ing an app or activity will delete all its associated versions!

Note that for all workitems kindly provide signed URL for the expected output file. Else the workitem post will result with failedUpload.

REST API documentation on Design Automation V3 can be found here.

Written by

Jaime Rosales D. Twitter Follow

Forge Partner Development