Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
add support for appbundle & activity config
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnOnSoftware committed Aug 27, 2019
1 parent 1537468 commit 17706c8
Show file tree
Hide file tree
Showing 15 changed files with 860 additions and 51 deletions.
Binary file removed FileUpgrader/PlugIn/FileUpgraderApp.zip
Binary file not shown.
18 changes: 11 additions & 7 deletions FileUpgrader/PlugIn/Source/FileUpgrader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<ItemGroup>
<Reference Include="DesignAutomationBridge">
<HintPath>C:\Program Files\Autodesk\Revit 2019\DesignAutomationBridge.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="RevitAPI">
Expand Down Expand Up @@ -100,17 +100,21 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="FileUpgrader.addin">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="PackageContents.xml" />
<Content Include="FileUpgraderApp.bundle\Contents\FileUpgrader.addin" />
<Content Include="FileUpgraderApp.bundle\Contents\FileUpgrader.dll" />
<Content Include="FileUpgraderApp.bundle\PackageContents.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(ProjectDir)FileUpgrader.addin" "$(AppData)\Autodesk\REVIT\Addins\2019"
copy "$(ProjectDir)bin\debug\FileUpgrader.dll" "$(AppData)\Autodesk\REVIT\Addins\2019"</PostBuildEvent>
<PostBuildEvent>
xcopy /Y /F "$(ProjectDir)FileUpgraderApp.bundle\Contents\FileUpgrader.addin" "$(AppData)\Autodesk\REVIT\Addins\2019"
xcopy /Y /F "$(ProjectDir)bin\Debug\FileUpgrader.dll" "$(AppData)\Autodesk\REVIT\Addins\2019”
xcopy /Y /F "$(TargetDir)*.dll" "$(ProjectDir)FileUpgraderApp.bundle\Contents\"
del /F "$(ProjectDir)..\..\..\public\bundles\FileUpgraderApp.zip"
"C:\Program Files\7-Zip\7z.exe" a -tzip "$(ProjectDir)../../../public/bundles/FileUpgraderApp.zip" "$(ProjectDir)FileUpgraderApp.bundle\" -xr0!*.pdb
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Components Description="File upgrade app">
<RuntimeRequirements OS="Win64"
Platform="Revit"
SeriesMin="R2019"
SeriesMin="R2018"
SeriesMax="R2019" />
<ComponentEntry AppName="FileUgrader"
Version="1.0.0"
Expand Down
41 changes: 14 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ This sample demostrated how to upgrade Revit project/family/template to the late

# Main Parts of The Work
1. Create a Revit Plugin to be used within AppBundle of Design Automation for Revit. Please check [PlugIn](./FileUpgrader/PlugIn/)
2. Create your App, upload the AppBundle, define your Activity and test the workitem with the Postman collection under [Postman Collection](./FileUpgrader/PostmanCollection/)

2. Create your App, upload the AppBundle, define your Activity and test the workitem with the Postman collection under [Postman Collection](./FileUpgrader/PostmanCollection/), or you can refer ([https://youtu.be/1NCeH7acIko](https://youtu.be/1NCeH7acIko)) and simply use the `Configure` button in the Web Application to create the Appbundle & Activity.
3. Create the Web App to call the workitem.

# Web App Setup
Expand Down Expand Up @@ -70,9 +69,8 @@ Mac OSX/Linux (Terminal)
export FORGE_CLIENT_SECRET=<<YOUR CLIENT SECRET>>
export FORGE_CALLBACK_URL=<<YOUR CALLBACK URL>>
export FORGE_WEBHOOK_URL=<<YOUR DESIGN AUTOMATION FOR REVIT CALLBACK URL>>
export REVIT_IO_NICK_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT NICK NAME>>
export REVIT_IO_APP_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT APP NAME>>
export REVIT_IO_ACTIVITY_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT ACTIVITY NAME>>
export DESIGN_AUTOMATION_NICKNAME=<<YOUR DESIGN AUTOMATION FOR REVIT NICK NAME>>
export DESIGN_AUTOMATION_ACTIVITY_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT ACTIVITY NAME>>
npm start

Windows (use **Node.js command line** from Start menu)
Expand All @@ -82,9 +80,8 @@ Windows (use **Node.js command line** from Start menu)
set FORGE_CLIENT_SECRET=<<YOUR CLIENT SECRET>>
set FORGE_CALLBACK_URL=<<YOUR CALLBACK URL>>
set FORGE_WEBHOOK_URL=<<YOUR DESIGN AUTOMATION FOR REVIT CALLBACK URL>>
set REVIT_IO_NICK_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT NICK NAME>>
set REVIT_IO_APP_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT APP NAME>>
set REVIT_IO_ACTIVITY_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT ACTIVITY NAME>>
set DESIGN_AUTOMATION_NICKNAME=<<YOUR DESIGN AUTOMATION FOR REVIT NICK NAME>>
set DESIGN_AUTOMATION_ACTIVITY_NAME=<<YOUR DESIGN AUTOMATION FOR REVIT ACTIVITY NAME>>
npm start

### Using the app
Expand All @@ -93,30 +90,17 @@ Open the browser: [http://localhost:3000](http://localhost:3000), there are 2 wa

1. Select Revit file in BIM360 Hub from Source File/Folder, Right Click and select `Upgrade to Revit 2019`. It will create a new version after successfully upgraded.
2. Select Source Folder and Destination Folder, then click `Upgrade`, it will upgrade all the files under the folder to destinated folder.
`Note`: When you deploy the app, you have to open the `Configure` button to create the AppBundle & Activity before running the Export|Import feature, please check the video for the steps at [https://youtu.be/1NCeH7acIko](https://youtu.be/1NCeH7acIko)

## Deployment

## Main Backend API used
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, Callback URL and Revit Design Automation variables for Forge.

### File upgrade API based on Design Automation API at **routes/da4revit.js**
- POST /api/forge/da4revit/v1/upgrader/files/:source_file_url/folders/:destinate_folder_url
- POST /api/forge/da4revit/v1/upgrader/files
- GET /api/forge/da4revit/v1/upgrader/files/:file_workitem_id
- DELETE /api/forge/da4revit/v1/upgrader/files/:file_workitem_id
- POST /api/forge/callback/designautomation
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/Autodesk-Forge/design.automation-nodejs-revit.file.upgrader)

### File/Folder operation API based on Data Management API at **routes/datamanagement.js**
- POST /api/forge/datamanagement/v1/folder
- DELETE /api/forge//datamanagement/v1/folder/:folder_url
- GET /api/forge/datamanagement/v1
Watch [this video](https://www.youtube.com/watch?v=Oqa9O20Gj0c) as reference on how to deploy samples to Heroku.

### User information API at **routes/user.js**
- GET /api/forge/user/v1/profile

### OAuth information API at **routes/oauth.js**
- GET /api/forge/oauth/v1/url
- GET /api/forge/q/v1/signout
- GET /api/forge/oauth/v1/token
- GET /api/forge/oauth/v1/clientid
- GET /api/forge/callback/oauth

## Packages used

Expand All @@ -135,6 +119,9 @@ Desktop APIs:

- [Revit](https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/simplecontent/content/my-first-revit-plug-overview.html)

## Tips & Tricks
- Before using the sample to call the workitem, you need to setup your Appbundle & Activity of Design Automation, you can follow my Postman script to understand the whole process, or you can simply use the `Configure` button in the Web Application to create the Appbundle & Activity([https://youtu.be/1NCeH7acIko](https://youtu.be/1NCeH7acIko)).

## Troubleshooting

After installing Github desktop for Windows, on the Git Shell, if you see a ***error setting certificate verify locations*** error, use the following:
Expand Down
37 changes: 37 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "design.automation-nodejs-revit.file.upgrader",
"description": "This sample demostrated how to upgrade Revit project/family/template to the latest version using Design Automation for Revit API, including upgrade one file or one folder.",
"repository": "https://github.com/Autodesk-Forge/design.automation-nodejs-revit.file.upgrader",
"logo": "https://avatars0.githubusercontent.com/u/8017462?v=3&s=200",
"keywords": [
"autodesk",
"forge",
"design automation"
],
"env": {
"FORGE_CLIENT_ID": {
"description": "Forge Client ID"
},
"FORGE_CLIENT_SECRET": {
"description": "Forge Client Secret"
},
"FORGE_CALLBACK_URL": {
"description": "Callback URL of your Forge app, required for 3-legged OAuth",
"value": "https://<<YOUR HEROKU APP NAME HERE>>.herokuapp.com/api/forge/callback/oauth"
},
"FORGE_WEBHOOK_URL": {
"description": "Callback URL of your webhook",
"value": "http://<<YOUR HEROKU APP NAME HERE>>.herokuapp.com/api/forge/callback/designautomation"
},
"DESIGN_AUTOMATION_NICKNAME": {
"description": "Revit Design Automation NickName, FORGE_CLIENT_ID by default",
"value": "<<YOUR FORGE_CLIENT_ID HERE>>"
},
"DESIGN_AUTOMATION_ACTIVITY_NAME": {
"description": "Revit Design Automation Activity Name",
"value": "FileUpgraderAppActivity+dev"
}
},
"website": "https://developer.autodesk.com/",
"success_url": "/"
}
27 changes: 22 additions & 5 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,28 @@ module.exports = {
public: ['viewables:read']
},
designAutomation:{
revit_IO_WebHook_Url: process.env.FORGE_WEBHOOK_URL,
revit_IO_Endpoint: 'https://developer.api.autodesk.com/da/us-east/v3/',
revit_IO_Nick_Name: process.env.REVIT_IO_NICK_NAME,
revit_IO_App_Name: process.env.REVIT_IO_APP_NAME,
revit_IO_Activity_Name: process.env.REVIT_IO_ACTIVITY_NAME,
endpoint: 'https://developer.api.autodesk.com/da/us-east/v3/',
webhook_url: process.env.FORGE_WEBHOOK_URL,
nickname: process.env.DESIGN_AUTOMATION_NICKNAME,
activity_name: process.env.DESIGN_AUTOMATION_ACTIVITY_NAME,
appbundle_activity_alias: 'dev',

URL:{
GET_ENGINES_URL: "https://developer.api.autodesk.com/da/us-east/v3/engines",
ACTIVITIES_URL: "https://developer.api.autodesk.com/da/us-east/v3/activities",
ACTIVITY_URL: "https://developer.api.autodesk.com/da/us-east/v3/activities/{0}",
APPBUNDLES_URL: "https://developer.api.autodesk.com/da/us-east/v3/appbundles",
APPBUNDLE_URL: "https://developer.api.autodesk.com/da/us-east/v3/appbundles/{0}",

CREATE_APPBUNDLE_VERSION_URL: "https://developer.api.autodesk.com/da/us-east/v3/appbundles/{0}/versions",
CREATE_APPBUNDLE_ALIAS_URL: "https://developer.api.autodesk.com/da/us-east/v3/appbundles/{0}/aliases",

UPDATE_APPBUNDLE_ALIAS_URL: "https://developer.api.autodesk.com/da/us-east/v3/appbundles/{0}/aliases/{1}",
CREATE_ACTIVITY_ALIAS: "https://developer.api.autodesk.com/da/us-east/v3/activities/{0}/aliases",
}



}


Expand Down
Binary file added public/bundles/FileUpgraderApp.zip
Binary file not shown.
66 changes: 64 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
<!-- this project files -->
<link href="css/main.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<script src="js/DAConfigure.js"></script>
<script src="js/ForgeTree.js"></script>
</head>

<body>
<!-- Fixed navbar by Bootstrap: https://getbootstrap.com/examples/navbar-fixed-top/ -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<ul class="nav navbar-nav left col-lg-7">
<ul class="nav navbar-nav left col-lg-6">
<li>
<a href="http://developer.autodesk.com" target="_blank">
<img alt="Autodesk Forge" src="//developer.static.autodesk.com/images/logo_forge-2-line.png" height="20">
Expand All @@ -33,7 +34,7 @@
</ul>


<ul class="nav navbar-nav right col-lg-3">
<ul class="nav navbar-nav right col-lg-2">
<li>
<div style="float: right; margin-top: 15px;">
<span style="padding-right: 5px;" data-toggle="modal" data-target="#provisionAccountModal" title="Enable my BIM 360 Account"><span
Expand All @@ -42,6 +43,16 @@
</li>
</ul>

<ul class="nav navbar-nav right col-lg-2">
<li>
<div style="float: right; margin-top: 15px; cursor: pointer;">
<span style="padding-right: 5px;" data-toggle="modal" data-target="#defineActivityModal"
title="Configura AppBundle & Activity">
<span class="glyphicon glyphicon-cog glyphiconTop mlink"></span> Configure
</span>
</div>
</li>
</ul>

<ul class="nav navbar-nav right col-lg-2">
<div style="padding-top: 10px; text-align: right;">
Expand Down Expand Up @@ -209,6 +220,57 @@ <h4>Progress</h4>
</div>
</div>

<!-- Modal Define AppBundle & Activity -->
<div class="modal fade" id="defineActivityModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Cancel"><span
aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">AppBundle & Activity</h4>
</div>
<div class="modal-body">
<div class="alert alert-warning">
<center>Define AppBundle &amp; Activity only once.<br />Redefine only when your plugin code change
(creates a new version).</center>
</div>
<div class="form-group">
<label for="localBundles">Select a local AppBundle:</label>
<select class="form-control" id="localBundles"> </select>
<b>Tip:</b> Make sure .ZIP bundles are placed at <b>/bundles/</b> folder
</div>
<div class="form-group">
<label for="engines">Select engine:</label>
<select class="form-control" id="engines"> </select>
</div>
For this sample the .ZIP name is used as suffix to define <b>AppBundle</b> and <b>Activity</b>
names. Activities will have the following parameters: <br>
&nbsp&nbsp&nbsp&nbsp<b>rvtFile:</b> Input Revit model <br>
&nbsp&nbsp&nbsp&nbsp<b>resultrvt:</b> Output upgraded revit Rvt file <br>
&nbsp&nbsp&nbsp&nbsp<b>resultrfa:</b> Output upgraded revit Rfa file <br>
&nbsp&nbsp&nbsp&nbsp<b>resultrte:</b> Output upgraded revit Rte file <br>
<div style="text-align: left;">
<label id="configText">
<h4>Status</h4>
</label>
</div>
<div>
<div class="progress progress-striped active">
<div id='configProgressBar' width=90% class="progress-bar progress-bar-success" role="progressbar"
aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
<span class="sr-only">40% 完成</span>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="createAppBundleActivity">Create/Update</button>
<button class="btn btn-danger" id="clearAccount">Delete</button>
</div>
</div>
</div>
</div>

<!-- Modal Provision BIM360 -->
<div class="modal fade" id="provisionAccountModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
Expand Down
Loading

0 comments on commit 17706c8

Please sign in to comment.