autodesk-platform-services / aps-configurator-inventor

Inventor Configurator:A showcase application for Design Automation API for Inventor
https://inventor-config-demo.autodesk.io
MIT License
15 stars 5 forks source link
autodesk-designautomation autodesk-inventor dotnet nodejs

Configurator Inventor

Demo application showcasing Configuration with Design Automation for Inventor

thumbnail

Architecture

thumbnail

Prerequisites

Web Application

  1. .NET Core 3.1
  2. Node.js
    Important note: In Node.js even releases are stable, and odd-numbered versions are unstable. That's said we won't support or guarantee the work of the application using the odd-numbered Node.js versions. Currently the latest version we support is the even version v16.13.2. Unless version v18 will be released we are not supporting versions newer than v16.
  3. (recommended) Visual Studio Code with extensions:
  4. Autodesk Inventor 2021
  5. Visual Studio 2022

Run sample for the first time

  1. Clone repository

  2. Create an APS app at https://aps.autodesk.com/, and select Design Automation API and Data Management API in the APIs section thumbnail

  3. Enter https://localhost:5001 as the callback URL

  4. Note the Client ID and Client Secret generated

  5. Specify APS credentials using one of the following approaches:\ a) Set environment variables APS_CLIENT_ID and APS_CLIENT_SECRET\ b) Set environment variables Forge__ClientId and Forge__ClientSecret\ c) Make a copy of appsettings.Local.template.json in the WebApplication directory named appsettings.Local.json and replace the <clientId> and <clientSecret> in it\ d) (not on dev machine) Modify appsettings.json (or appsettings.<ENVIRONMENT>.json) with the template mentioned in c)\ e) Set environment variable 'set NODE_ENV=development'

  6. Make a copy of InventorBinFolder.props.template in the top AppBundles folder named InventorBinFolder.props and replace the PATH_TO_YOUR_INVENTOR_BIN string in it with your actual Inventor bin folder path, for example: C:\Program Files\Autodesk\Inventor 2021\Bin then right-click on the solution in the Solution Explorer window and select Load All Projects

  7. (Optional) Choose network configuration for your application. By default polling is enabled as it offers an easier way to setup and run the application. This is OK for locally run applications and debugging. However in production using the new callback option is highly recommended to conserve resources. In order to enable the callback option modify the Publisher section of the appsettings.json file. Change "CompletionCheck" value from "Polling" to "Callback" and set "CallbackUrlBase" url to your server URL or ngrok tunnel URL for a locally run application. To run and debug callbacks locally please refer to the ngrok section

  8. (Optional) Specify if access should be limited in WebApplication\appsettings.json. Set Enabled to true or false, and populate the Domains and Addresses fields with comma delimited lists such as ["autodesk.com", "company.com"] and ["person@company2.com", "person@company3.com"]

  9. Open the aps-configurator-inventor.sln file with Visual Studio 2022 and build the solution thumbnail\ This will also generate the zip files of all the app bundles that the web app will need to upload to the Design Automation server\ thumbnail\ When building the solution, make sure that all those app bundles got generated successfully thumbnail\ Now we have to initialize things both on the Design Automation server and locally. In the terminal (in Visual Studio or outside) navigate to the WebApplication folder and run dotnet run initialize=true thumbnail\ Once the output reaches the Now listening on: https://localhost:5001 line just open that URL in your browser\ Next time you'll also be able to start the app from the Visual Studio debugger. In the Debug drop-down menu select aps-configurator-inventor and start debugging thumbnail This time your browser should open up automatically showing the correct URL

Build

Web Application and App Bundles

Web Application Alone

(Optional) Update the npm packages

Run The Web Application Without Debugging

Clear and load initial data during app launch time

Debug The Web Application With VS Code

  1. Make sure that application is fully initialized, before you start debugging session. Please see the Clear and load initial data
  2. Open the repository root folder in VS Code
  3. In the Run tab, select the Server/Client configuration and click the "Start Debugging" (arrow) button
    • Some browser errors are normal, see open site
    • Disregard C# errors related to AppBundles in VS Code

Run/Debug Tests

Backend

  1. From the WebApplication/ClientApp directory:
    • For all UI tests Run this command: npx codeceptjs run or npm run uitest.
    • For particular file you can use this command: npx codeceptjs run src/ui-tests/<test file name>

Backend

We are using the APS service on the backend https://aps.autodesk.com/

.NET Core

We are using the latest version of .NET Core (3.1 at the time of writing) https://dotnet.microsoft.com/download/dotnet-core/3.1

The project was initally created using the command dotnet new react

Design Automation

https://aps.autodesk.com/en/docs/design-automation/v3/developers_guide/overview/

C# SDK https://github.com/Autodesk-Forge/forge-api-dotnet-design.automation

We are using the Inventor and Revit engines.

OSS

Used for storing your designs. For communication with Design Automation

https://aps.autodesk.com/en/docs/data/v2/developers_guide/overview/

C# SDK https://github.com/Autodesk-Forge/forge-api-dotnet-client

Client app

React

https://reactjs.org/

Redux

https://redux.js.org/

We are using redux-thunk for complex and asynchronous operations https://github.com/reduxjs/redux-thunk

Redux DevTool

In index.js replace

const store = createStoreWithMiddleware(mainReducer);

with

const store = createStoreWithMiddleware(mainReducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());

Autodesk HIG React

https://github.com/Autodesk/hig

Table is not part of todays React HIG implementation so we will use https://github.com/Autodesk/react-base-table

How to

Add npm package to project

We are using npm.

  1. Using command line go to WebApplication/ClientApp and run npm install <package>
    • Note that packages are normally installed as part of the build, but only if the npm_modules directory is not found. This means that when new packages are added, WebApplication/ClientApp/npm install needs to be run again manually by other users (who did not add the new package).

Manually run linter

Deploy

Project file zip encoding

Use ngrok for localhost callbacks