All Projects → Autodesk-Forge → design.automation-python-tutorial

Autodesk-Forge / design.automation-python-tutorial

Licence: MIT license
Design Automation sample in Python: Shows how to get token and check the status of one existing work item

Programming Languages

python
139335 projects - #7 most used programming language
C#
18002 projects

Projects that are alternatives of or similar to design.automation-python-tutorial

forge-createfamily-revit
Window Family Creation Sample of Design Automation for Revit
Stars: ✭ 19 (-34.48%)
Mutual labels:  autodesk-designautomation
forge-checkmodels-createissues-revit
Design Check with Design Automation for Revit: Perform a basic design check on models uploaded to BIM 360 and log conflicts as Issues
Stars: ✭ 19 (-34.48%)
Mutual labels:  autodesk-designautomation

Design Automation API workflow sample in Python

(Formely I/O).

ver tls1.2 Platforms Data-Management Design-Automation

oAuth2 Data-Management OSS

License

Description

This is a Python sample code for Design Automation API (DA) (v3). It demos the workflow on updating the width and height param of DWG Dynamic Block (using AutoCAD), RVT Window Family instance (using Revit), IPT Part parameters (using Inventor) and 3DS ... (using 3dsMax). The source demo files and plugin projects are cloned from learn.forge.designautomation

Thumbnail

thumbnail

Dependencies

  • Python: Download Python. The code can work with old version such as 2.7.9, but it requires to have TLS1.2 supported. It is recommended to use Python > 3.
  • Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial. Make sure to select the service Design Automation API V3 (beta). Make a note with the credentials (client id and client secret) of the app.
  • Plugin: Build the the plugin in Plugins folder by corresponding version of Visual Studio and refererences of correspoinding Autodesk products. The app bundle zip will be put to bundles folder by post-build event
  • Install dependencies via pip:
    pip install -r requirements.txt

Running locally

  1. input the credentials (client_id and client_secret) config.py. Input desired nickname and alais.
    #Forge Client Id
    Forge_CLIENT_ID = ''
    #Forge Client Secret
    Forge_CLIENT_SECRET =''
    #desired nick name
    desired_nickname = 'xiaodonglikename'   
    #Alias
    alias = 'dev' 
  1. run main.py with width and height value:
    • python main.py --height [height value] --width [width value]
  1. Follow the note of command line to select: bundle, app engines. The code will re-use the name of bundle name as the appBundle name and activity name of DA. Ensure to select the suitable engines for the corresponding bundle.

  2. The code will create a new activity or appbundle if they do not exist. If they exist, one new version will be generated.

  3. Before posting workitem, the code will upload the demo source file to OSS bucket of your Forge account. The updated model file will also be put to OSS bucket, with a new name.

  4. Wait for the response about work item status. If it success, the output model file (model with the updated parameters) will be downloaded to output folder. Try with other tool (such as https://viewer.autodesk.com ) to verify if the model is valid and parameters are updated. If it fails, the log file will be downloaded to report folder.

Demo Video

Click the image below to check the demo video: Forge Design Automation Python Workflow

Troubleshooting

  1. When installing depencencies, for such similar error as below, try to upgrade pip
Could not fetch URL https://pypi.python.org/simple/pathlib/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)
  1. When running the code, it failed with such error below, check if TLS1.2 and above is supported with SSL request with this Python enviroment.
requests.exceptions.SSLError: HTTPSConnectionPool(host='developer.api.autodesk.com', port=443): Max retries exceeded with url: /authentication/v1/authenticate (Caused by SSLError(SSLEOFError(8, u'EOF occurred in violation of protocol (_ssl.c:590)'),))

The best is to upgrade Python to version which > 3. Or try to install requests by security if in old version of Python, e.g.

pip install requests[security]

Further Reading

License

These samples are licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Authors

Autodesk Forge Support

See more at Forge blog.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].