JavaScript sample to extract Revit files from Model Derivative API as Spreadsheet (Excel XLSX)
This sample uses Model Derivative API endpoints to read a Revit project properties and create a XLSX Excel file with one sheet for each type/category with all objects on it. Non-Revit files are not supported (different structure). Here is another version for desktop.
Run it live at this page, or locally by following these steps:
- create a Forge application if you don't have one yet (tutorial)
- make sure you have at least one file prepared for viewing (tutorial)
- clone this git repository
- navigate to the repository root folder and install npm dependencies
- on Windows/macOS/Linux:
npm install
- on Windows/macOS/Linux:
- prepare required environment variables
- on Windows:
set FORGE_CLIENT_ID=<your client id> set FORGE_CLIENT_SECRET=<your client secret> set FORGE_BUCKET=<your data bucket>
- on macOS/Linux:
export FORGE_CLIENT_ID=<your client id> export FORGE_CLIENT_SECRET=<your client secret> export FORGE_BUCKET=<your data bucket>
- on Windows:
- run the application
- on Windows/macOS/Linux:
npm run dev
- on Windows/macOS/Linux:
- go to http://localhost:3000
Add reference to the ForgeXLS file:
<script src="ForgeXLS.js"></script>
Then call downloadXLSX method passing the URN and a data:read token.
function downloadExcel() {
ForgeXLS.downloadXLS(theURN, token, statusCallback /*Optional*/);
}
This project depends on Sheet JS to manipulate spreadsheet files. The FileSaver library is used to create & download a file on the client. BlobJS is required for older browsers (see compatibility). jQuery is also used.
<script src="jquery.min.js"></script>
<script src="Blob.js"></script>
<script src="FileSaver.min.js"></script>
<script src="xlsx.core.min.js"></script>
This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.
Augusto Goncalves @augustomaia, Forge Partner Development