This sample demonstrates using the Forge Design Automation for Revit API to extract additional information from a model. The user can select a RVT file hosted on BIM 360 Document Manager or A360 and view it using the Forge Viewer.
Once the file has been loaded, a Design Automation workitem will run a .NET plugin in the background to extract Compound Layer Structure information from the file. When ready, the information will be visible in the property panel.
This sample is based on the Learn Forge tutorials in the section List hubs & projects.
- Forge Account: Learn how to create a Forge Account, activate subscription and create an app at this tutorial.
- Visual Studio: Either Community (Windows) or Code (Windows, MacOS).
- .NET Core: basic knowledge of C#.
- ngrok: Routing tool, download here.
- Revit 2020: required to compile changes into the plugin. Windows only.
Use of this sample requires Autodesk developer credentials.
Visit the Forge Developer Portal, sign up for an account
and create an app that uses Data Management and Model Derivative APIs.
For this new app, use http://localhost:3000/api/forge/callback/oauth
as Callback URL, although is not used in a 2-legged flow.
Finally, make a note of the Client ID and Client Secret.
Clone this project or download it. We recommend installing GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):
git clone https://github.com/augustogoncalves/forge-customproperty-revit
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.
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",
"FORGE_WEBHOOK_URL": "your ngrok address here: e.g. http://abcd1234.ngrok.io"
},
Revit plugin
A compiled version of the Revit
plugin (.bundles) is included on the webapp
module in the wwwroot/bundles
folder.
Any changes to these plugins will require the creation of a new .bundle; the Post-build event should handle that.
Start the app.
Open http://localhost:3000
to start the app and select a RVT file.
A pop-up will indicate when the style information is ready.
To deploy this application to Heroku, the Callback URL for Forge must use your .herokuapp.com
address.
After clicking on the button below on the the Heroku 'Create New App' page, set your Client ID, Secret and Callback URL for Forge.
Documentation:
-
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.
-
error setting certificate verify locations error: may happen on Windows, use the following:
git config --global http.sslverify "false"
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Augusto Goncalves @augustomaia, Forge Advocate