Skip to main content

Python SDK for Autodesk Platform Services Automation API

Project description

APS Automation SDK [Draft/Preliminary Version]

A Python SDK that wraps the Autodesk Platform Services (APS) Design Automation API, making it faster and easier to automate Revit and AutoCAD workflows in the cloud.

SDK vs REST API Comparison

The following comparison clearly shows how the aps_automation_sdk simplifies workflows compared to using the REST API directly. For complete examples, refer to the examples folder.

SDK REST API
# 1. Define input parameter
input_revit = ActivityInputParameter(
    name="rvtFile",
    localName="input.rvt",
    verb="get",
    description="Input Revit File",
    required=True,
    is_engine_input=True,
    bucketKey="yourBucketKey",
    objectKey="input.rvt",
)

# 2. Define output parameter
output_file = ActivityOutputParameter(
    name="result",
    localName="result.rvt",
    verb="put",
    description="Results",
    zip=False,
    bucketKey="yourBucketKey",
    objectKey="result.rvt",
    required=True,
)

# 3. Create activity
activity = Activity(
    id=activity_name,
    parameters=[input_revit, output_file],
    engine="Autodesk.Revit+2024",
    appbundle_full_name=appbundle_full_alias,
    description="Delete walls from Revit file Updated.",
    alias=alias,
)

# 4. Deploy activity
activity.set_revit_command_line()
activity.deploy(token=token)

# 5. Upload input file
input_rvt_path = Path.cwd() / "files" / "DeleteWalls.rvt"
input_revit.upload_file_to_oss(file_path=str(input_rvt_path), token=token)

# 6. Create work item
work_item = WorkItem(
    parameters=[input_revit, output_file],
    activity_full_alias=activity_full_alias
)

# 7. Execute and monitor work item
status_resp = work_item.execute(token=token, max_wait=600, interval=10)
# 1. Create activity
curl -X POST  'https://developer.api.autodesk.com/da/us-east/v3/activities'  -H 'Content-Type: application/json'  -H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'  -d '{
            "id": "DeleteWallsActivity",
            "commandLine": [ "$(engine.path)\\\\revitcoreconsole.exe /i \"$(args[rvtFile].path)\" /al \"$(appbundles[DeleteWallsApp].path)\"" ],
            "parameters": {
              "rvtFile": {
                "zip": false,
                "ondemand": false,
                "verb": "get",
                "description": "Input Revit model",
                "required": true,
                "localName": "$(rvtFile)"
              },
              "result": {
                "zip": false,
                "ondemand": false,
                "verb": "put",
                "description": "Results",
                "required": true,
                "localName": "result.rvt"
              }
            },
            "engine": "Autodesk.Revit+2024",
            "appbundles": [ "<YOUR_NICKNAME>.DeleteWallsApp+test" ],
            "description": "Deletes walls from Revit file."
    }'

# 2. Create activity alias
curl -X POST  'https://developer.api.autodesk.com/da/us-east/v3/activities/DeleteWallsActivity/aliases'  -H 'Content-Type: application/json'  -H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'  -d '{
      "version": 1,
      "id": "test"
    }'

# 3. Create bucket
curl -X POST \
    'https://developer.api.autodesk.com/oss/v2/buckets' \
    -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
    -H 'Content-Type: application/json' \
    -H 'x-ads-region: US' \
        -d '{
            "bucketKey": "<YOUR_BUCKET_KEY>",
            "access": "full",
            "policyKey": "transient"
        }'

# 4. Get signed upload URL
curl -X GET  "https://developer.api.autodesk.com/oss/v2/buckets/<YOUR_BUCKET_KEY>/objects/YOUR_OBJECT_KEY/signeds3upload"
     -H "Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT"

# 5. Upload file to S3
curl -X PUT  "<SIGNED_UPLOAD_URL>"
     -H --data-binary '@<PATH_TO_FILE_TO_UPLOAD>/deleteWalls.rvt'

# 6. Complete upload
curl -X POST  "https://developer.api.autodesk.com/oss/v2/buckets/<YOUR_BUCKET_KEY>/objects/<OBJECT_KEY_4_INPUT_FILE>/signeds3upload"  -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>"  -d '{
            "uploadKey": "<YOUR_UPLOAD_KEY>"
        }'

# 7. Create and execute work item
curl -X POST  'https://developer.api.autodesk.com/da/us-east/v3/workitems'  -H 'Content-Type: application/json'  -H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'  -d '{
        "activityId": "<YOUR_APP_NICKNAME>.DeleteWallsActivity+test",
        "arguments": {
          "rvtFile": {
            "url": "urn:adsk.objects:os.object:<YOUR_BUCKET_KEY>/<OBJECT_KEY_4_INPUT_FILE>",
              "verb": "get",
              "headers": {
                  "Authorization": "Bearer <YOUR_ACCESS_TOKEN>"
              }
          },
          "result": {
            "url": "urn:adsk.objects:os.object:<YOUR_BUCKET_KEY>/<RESULT_FILE_OBJECT_KEY>",
                              "verb": "put",
              "headers": {
                  "Authorization": "Bearer <YOUR_ACCESS_TOKEN>"
              }
          }
        }
      }'

# 8. Monitor work item status
curl -X GET  'https://developer.api.autodesk.com/da/us-east/v3/workitems/YOUR_WORKITEM_ID'  -H 'Content-Type: application/json'  -H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'

Installation

Prerequisites

  1. Install uv (fast Python package manager):

    pip install uv
    

    For other installation methods, see: https://docs.astral.sh/uv/getting-started/installation/

  2. Clone or download this repository

Install the SDK

From the project root directory:

# Install the package in editable mode
uv venv
source .venv/bin/activate   # on Windows: .venv\Scripts\activate
uv pip install -e .

Note: When running the Jupyter notebook in VS Code for the first time, you may be prompted to install the ipykernel package. Click "Install" or run:

uv add ipykernel

Configuration

Create a .env file in the project root with your APS credentials:

CLIENT_ID=your_client_id_here
CLIENT_SECRET=your_client_secret_here

Get your credentials from the APS Developer Portal.

Road Map

  • Improve type hints and docstrings
  • Add ACC examples
  • Add unit tests
  • Add pre-commits and governance
  • Migrate to Viktor

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aps_automation_sdk-0.1.0.tar.gz (55.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aps_automation_sdk-0.1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file aps_automation_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: aps_automation_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 55.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for aps_automation_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e6d25785e26695c1b68baa84a4488dc997c46c63d1c72d14b8d9375a209f1d5
MD5 ebdd34bff9ee6892a5baff79acc895e3
BLAKE2b-256 3a3993b6538604b99571d3a07fd266fe5f4695a1ffabf659a44996530413c605

See more details on using hashes here.

File details

Details for the file aps_automation_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aps_automation_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2142f5e8736dd8d767a36944d126d18e20b88d541c986120972f38d782f90915
MD5 15267efa30ca129bad3e144e57cb6652
BLAKE2b-256 2a61811563f068686cdd1017b0a01197c3d1b0a4fee40a409c0827b84a680caf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page