autodesk-platform-services / aps-revit.ifc.scheduler

This code sample demonstrates the usage of Model Derivative API, which allows you to convert a Revit `.rvt` file stored in Autodesk Docs(ACC/BIM360) to `.ifc` format.
Apache License 2.0
3 stars 1 forks source link

# Revit to IFC Scheduler Platforms .NET License

OAuth2 Data-Management Model-Derivative ACC Account-Admin

Advanced

Contents

Description

This code sample demonstrates the usage of Model Derivative API, which allows you to convert a Revit .rvt file stored in ACC/BIM360 Docs to .ifc format.

The IFC file format is a common transfer format used throughout the world, and consumed by a wide range of applications. You can use this tool to automate tasks to convert Revit Files hosted in ACC/BIM360 Docs to IFC on a recurring basis.

Users choose either folders or specific files, then choose an IFC Settings Set name, and set a schedule on which the folders or files should be converted to IFC. At the scheduled time, the application creates model derivative jobs for each file, and uploads the IFC file into the same folder as the original Revit file. If the Revit file and IFC Settings Set name have not changed since the last conversion, no job will be created.

Note. Model Derivate API incurs cost. To view the current cost of the Model Derivative service, and to purchase Cloud Credits for file conversions, please view the APS Pricing page.

Thumbnail

Main Page

Limitations

Setup

Prerequisites

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-platform-services/aps-revit.ifc.scheduler.git

Visual Studio

Visual Studio Code

Edit the appsettings.Development.json file, adding your APS Client ID, Secret, emails for Application Admins, and your SQL Database connection string.

{
  "ClientId": "your id here",
  "ClientSecret": "your secret here",
  "AdminEmails": "your admin user emails here",
  "ConnectionStrings": {
    "SqlDB": "your sql server connection string here: e.g. Server=localhost;Database=RevitIFCScheduler;User=sa;Password=...;TrustServerCertificate=True;"
  }
}

Run the app. Open http://localhost:3000 in your browser to view the application.

App Settings Variables

Name Description Example Value
ClientId From the APS App created during Setup CL35ag54e6aghsaf4cacwe
ClientSecret From the APS App created during Setup aa46asffaws
AdminEmails Semicolon-separated list of email addresses admin@mycompany.com;bimmanager@mycompany.com
ConnectionStrings.SqlDB A SQL connection String _Server=MY-SERVER;Database=revit-to-ifc-scheduler;TrustedConnection=True;ConnectRetryCount=0

Optional App Settings

Name Description Default Value
AppId A name for the application, used when naming cookies and buckets revit-to-ifc
SendGridApiKey If email notifications are desired, an API key from SendGrid should be provided null
FromEmail The email address that SendGrid should attempt to put into the 'From' field null
ToEmail The email address that SendGrid should attempt to put into the 'To' field null
LogPath The specific path where log files should be stored null
IncludeShallowCopies Copying a file in ACC/BIM360 does not create a new file, only a reference to the original file, and cannot be passed to the model derivative service. Setting this to true will make a true copy of the file, and pass that to the model derivative service. true
TwoLegScope The APS scopes used by two legged tokens data:read data:create account:read
ThreeLegScope The APS scopes used by three legged tokens user:read data:read

Deployment Steps

Please see the Deployment Guide.

Using the Application

Please see the User Guide.pdf for additional details.

Initial Setup

  1. Navigate to the tool using your browser.
  2. Log in using your ACC/BIM360 account (your email address must be included in the AdminEmails Environment Setting)
  3. Navigate to Settings by clicking Settings in the top right corner
  4. Toggle on the desired ACC/BIM360 accounts.
  5. Add an IFC Settings Set Name using the Add IFC Settings Set Name button.

    Note. Check out What does an IFC Settings Set Contain? in the Further Reading section, if you don't know what it is.

Creating a one-off conversion to IFC

  1. Navigate to the tool using your browser.
  2. Log in using your ACC/BIM360 account.
  3. Choose a project on the left-hand side.
  4. Navigate through the folder tree until you see the desired folders or files.
  5. Select the checkboxes next to the desired folders or files.
  6. Press Convert Selected to IFC Now in the upper right-hand corner.
  7. Choose the desired IFC Settings Set Name, or type in a new name.
  8. The conversion will begin immediately, but may take several minutes to complete.
  9. To view the status of the conversion, press the Conversion History button to see all past conversions within this project.

Creating a scheduled conversion to IFC

  1. Navigate to the tool using your browser.
  2. Log in using your ACC/BIM360 account.
  3. Choose a project on the left-hand side.
  4. Navigate through the folder tree until you see the desired folders or files.
  5. Select the checkboxes next to the desired folders or files.
  6. Press Create Schedule Conversion in the upper right-hand corner.
  7. The application will automatically create a scheduled run on a daily schedule.
  8. You may change the following settings for the schedule:
    1. Schedule Name
    2. IFC Settings Set Name
    3. Frequency (Daily, Weekly, etc.)
    4. The days on which the schedule should repeat
    5. The time at which the schedule should repeat
    6. The time zone at which the schedule should repeat
  9. The conversion will begin at the next scheduled event.
  10. To view the status of the conversion, press the Conversion History button to see all past conversions within this project.

Conversion Statuses

Name Description
Created The IFC conversion job is created and enqueued successfully.
Processing The Revit model has been sent to the Model Derivative service, and is being converted to IFC.
Converted The model has been converted to IFC, but has not yet been uploaded to ACC/BIM360 Docs.
Success The status of the IFC conversion job is success and has been uploaded to the BIM360 Docs folder where the source Revit file is.
Failed The conversion or upload could not be completed. Please click the conversion record for more details.
Unchanged This model has previously been converted to IFC using the same IFC setting set. No additional conversion is required.
ShallowCopy The selected Revit file is a copy, rather than an uploaded file. To convert this file, set AllowShallowCopies to true in your App Settings Variables.
TimeOut The APS Model Derivative service has returned a timeout error.

Further Reading

Documentation:

Related knowledge:

Tips and Tricks:

Sending Confirmation Emails

This tool uses SendGrid to send a confirmation email on a successful conversion. This requires creating a free SendGrid account (for up to 25,000 emails/month), verifying a 'Single Sender' email address, and retrieving an API Key with 'Send' authorization. Three optional environment settings must be set: SendGridApiKey, FromEmail, and ToEmail. If any one of these is left blank, no emails will be sent.

SendGrid can be setup by creating an account at www.sendgrid.com, or by creating a SendGrid Accounts resource from the Azure Portal.

Internationalization - Additional Language Support

This application is capable of supporting multiple languages -- by default, English and Norwegian have been provided. To add additional languages, copy the folder located at aps-revit.ifc.scheduler/ClientApp/public/locales/en, and rename it with the appropriate language code. Search for the file named i18next.ts, and add the language code to the fallbackLng array. Finally, edit the translation.json and scheduler.json files in the folder that you just copied, and set the values on the right hand side to the appropriate translation.

When this is done, an additional language code will be shown in the header bar of the application.

Shallow Copies

When a file is 'shallow copied', and ACC/BIM360 makes a reference to a file that's already claimed by another BIM360 file, it can't be processed via the Model Derivative service. This happens within 'Shared' folders, and when a user makes use of the 'copy' function. The IncludeShallowCopies optional environment setting allows us to get around this, by making a copy of the file on OSS, then translating that instead.

Modifying the Database

This tool uses Entity Framework Core in a code-first, migration based setup. Provide it with a connection string, and it will automatically create or update the database and tables as needed.

When the tables are modified in the Data project, you will need to create a new Migration. Do do this, navigate to the 'BIM360 - Revit to IFC Converter' project, and run the following command: dotnet ef migrations add NameOfYourMigrationHere. The migration will be applied during the next application run.

Troubleshooting

  1. Cannot see my ACC/BIM360 projects:

    • Make sure to provision the APS App Client ID within the ACC/BIM360 Account, learn more here. (This requires the Account Admin permission)
    • Also, check section 2.1 Login and section 2.3.1 Enabling a BIM360 account of UserGuide.pdf for instructions.
  2. Received Microsoft.Data.SqlClient.SqlException while starting this app: if it indicates that there is already an object named 'XXXXX' in the database, then this means the database you specified in appsetings.json is not empty. You can fix it by doing either of the below ways:

    • Comment out the dbContext.Database.Migrate(); in Startup.cs, then restart the app.
    • Backup your database, erase the database by executing DROP DATABASE command in the SQL Server Management Studio, and then restart the app.
  3. See 401 Unauthorized error after logging in:

    • Check if the user level of the user account you logged in matches the listed roles of the section 2.1 Login of UserGuide.pdf.
    • If the user level of your user account is Application Admins, ensure that your user email is specified in the AdminEmails of the App Settings Variables.

License

This application is licensed under Apache 2.0. For details, please see LICENSE.md.

Written By