Giter VIP home page Giter VIP logo

dukedhx / design.automation-csharp-inventor2revit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from autodesk-forge/forge-update-revitfamily-from-inventorpart

0.0 2.0 0.0 9.56 MB

Update Family into Revit models with Design Automation for Inventor & Revit: Export IPT files to SAT, then create new RFA and replace on existing RVT projects and save back to BIM 360

Home Page: http://inventor2revit.herokuapp.com

License: MIT License

C# 83.44% CSS 0.31% HTML 7.37% JavaScript 8.88%

design.automation-csharp-inventor2revit's Introduction

design.automation-csharp-inventor2revit

Platforms .NET oAuth2 Data-Management Webhook Design-Automation

Platforms .NET Inventor Revit

Advanced License

Description

This sample monitors a BIM 360 Folder for version.added event, when a new IPT file (or version) is uploaded, it triggers Design Automation for Inventor to convert it to .SAT file. Then triggers Design Automation for Revit to import this SAT file into a new Revit Family RFA (using a predefined Revit Family Template, RFT). Then opens a Revit RVT file (on the same folder where the IPT was uploaded) and updade the family. The resulting Revit file is uploaded back to BIM 360 as a new version.

This sample is based on this Webhook sample. Learn more about Webhooks and 3-legged Refresh & Access Token at this blog post. Also based on the Learn Forge Tutorial.

Thumbnail

thumbnail

Demonstration

Whatch the recording at Youtube.

Live version

Try it at inventor2revit.herokuapp.com, use the Table_Chair.rvt and both Chair_Orientation.ipt (with and without headrest) sample files at this folder

Setup

Prerequisites

  1. Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
  2. Visual Studio: Either Community (Windows) or Code (Windows, MacOS).
  3. .NET Core basic knowledge with C#
  4. ngrok: Routing tool, download here
  5. MongoDB: noSQL database, learn more. Or use a online version via MongoDB Atlas (this is used on this sample)
  6. AWS Account: S3 buckets are used to store temporary files
  7. Inventor 2019: required to compile changes into the plugin
  8. Revit 2019: required to compile changes into the plugin

Running locally

Clone this project or download it. It's recommended to install GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):

git clone https://github.com/autodesk-forge/design.automation-csharp-inventor2revit

Visual Studio (Windows):

Right-click on the project, then go to Debug. Adjust the settings as shown below.

Visual Sutdio Code (Windows, MacOS):

Open the folder, at the bottom-right, select Yes and Restore. This restores the packages (e.g. Autodesk.Forge) and creates the launch.json file. See Tips & Tricks for .NET Core on MacOS.

Important: For Visual Code (Windows or MacOS) open only the /web/ folder. This IDE doesn't recognize the Inventor & Revit plugins, so opening the entire solution may fail.

MongoDB

MongoDB is a no-SQL database based on "documents", which stores JSON-like data. For testing purpouses, you can either use local or live. For cloud environment, try MongoDB Atlas or Compose MongoDB. With MongoDB Atlas you can set up an account for free and create clustered instances.

There are several tools to view your database, Robo 3T (formerly Robomongo) is a free lightweight GUI that can be used. When it opens, follow instructions here to connect to MongoDB Atlas.

AWS Account

Create an AWS Account, allow API Access, the access key and secret key will be used on this sample.

ngrok

Run ngrok http 3000 -host-header="localhost:3000" to create a tunnel to your local machine, then copy the address into the FORGE_WEBHOOK_URL environment variable.

Environment variables

At the .vscode\launch.json, find the env vars and add your Forge Client ID, Secret and callback URL. Also define the ASPNETCORE_URLS variable. The end result should be as shown below:

"env": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "ASPNETCORE_URLS" : "http://localhost:3000",
    "FORGE_CLIENT_ID": "your id here",
    "FORGE_CLIENT_SECRET": "your secret here",
    "FORGE_CALLBACK_URL": "http://localhost:3000/api/forge/callback/oauth",
    "OAUTH_DATABASE": "mongodb+srv://<username>:<password>@cluster0-u9dtd.mongodb.net/test?retryWrites=true",
    "FORGE_WEBHOOK_URL": "your ngrok address here: e.g. http://abcd1234.ngrok.io",
    "AWS_ACCESS_KEY": "your AWS access key here",
    "AWS_SECRET_KEY": "your AWS secret key here"
},

Before running the sample, it's recomended to already upload a RVT project and a IPT file into a BIM 360 Folder. See /samplefiles folder.

A compiled version of the Inventor and Revit plugins (.bundles) are included on the web module. Any changes on these plugins will require to create a new .bundle as a .zip file, the Post-build event should create them. These file names are hardcoded.

Before start, upload the Table_Chair.rvt and Chair_Orientation.ipt to a BIM 360 folder.

Start the app from Visual Studio (or Visual Code). Open http://localhost:3000 to start the app, select a folder to start monitoring. Upload a new version of the IPT (Chair with headrest/Chair_Orientation.ipt, same name, but with headrest) file and the process should start. You can monitor the Jobs via Hangfire dashboard: http://localhost:3000/hangfire.

Deployment

To deploy this application to Heroku, the Callback URL for Forge must use your .herokuapp.com address. After clicking on the button below, at the Heroku Create New App page, set your Client ID, Secret and Callback URL for Forge.

Deploy

Further Reading

Forge Documentation:

Desktop APIs:

Other APIs:

Known Issues

  • This sample hardcode the Revit project to upload the IPT.

Tips & Tricks

This sample uses .NET Core and works fine on both Windows and MacOS, see this tutorial for MacOS. Important: For Visual Code (Windows or MacOS) open only the /web/ folder.

What connection string should I use for my MongoDB cluster?

If you are using MongoDB version earlier than 3.4 (default version as this sample), use the sharded schema: mongodb://<username>:<password>@cluster0-shard-00-00-u9dtd.mongodb.net:27017,cluster0-shard-00-01-u9dtd.mongodb.net:27017,cluster0-shard-00-02-u9dtd.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true

Otherwise go with the service schema which is much simpler: mongodb+srv://<username>:<password>@cluster0-u9dtd.mongodb.net/test?retryWrites=true

See here for details on connection string schema.

I have set everything up right but am still unable to connect to MongoDB Atlas?

Be sure to follow this tutorial to whitelist your server. Contact Forge Help if the problem persists.

Troubleshooting

  1. Cannot see my BIM 360 projects: Make sure to provision the Forge App Client ID within the BIM 360 Account, learn more here. This requires the Account Admin permission.

  2. error setting certificate verify locations error: may happen on Windows, use the following: git config --global http.sslverify "false"

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Forge Partner Development team:

  • Augusto Goncalves @augustomaia
  • Naveen Kumar T
  • Sajith Subramanian

design.automation-csharp-inventor2revit's People

Contributors

adamenagy avatar augustogoncalves avatar dukedhx avatar jaimerosales avatar sajith-subramanian avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.