https://github.com/cyrillef/propertyserver
Forge Model PropertyServer to workaround the Model Derivative API limitations
https://github.com/cyrillef/propertyserver
autodesk forge modelderivative
Last synced: over 1 year ago
JSON representation
Forge Model PropertyServer to workaround the Model Derivative API limitations
- Host: GitHub
- URL: https://github.com/cyrillef/propertyserver
- Owner: cyrillef
- License: mit
- Created: 2018-04-06T18:42:53.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-16T12:42:43.000Z (almost 8 years ago)
- Last Synced: 2025-04-23T00:48:00.857Z (over 1 year ago)
- Topics: autodesk, forge, modelderivative
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 5
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# propertyServer sample
[](https://nodejs.org/)
[](https://www.npmjs.com/)

[](http://opensource.org/licenses/MIT)
*Forge API*:
[](http://developer-autodesk.github.io/)
[](http://developer-autodesk.github.io/)
Note: For using this sample, you need a valid oAuth credential for accessing resources on Autodesk Forge.
Visit this [page](https://developer.autodesk.com) for instructions to get on-board.
## Description
The propertyServer server exercises a workaround to the Forge Model Derivative API limitations to [request properties](https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/urn-metadata-guid-properties-GET/).
It also demonstrates how to parse the bubble json.gz property files.
In order to make use of this sample, you need to register your consumer and secret keys:
* https://developer.autodesk.com > My Apps
This provides the credentials to supply to the http requests to the Autodesk server endpoints.
## Dependencies
This sample is dependent on the server part on Node.js and couple of Node.js extensions
which would update/install automatically via 'npm':
## Setup/Usage Instructions
### Deploy on Heroku
[](https://heroku.com/deploy)
### Setup
1. Download and install [Node.js](http://nodejs.org/) (that will install npm as well)
2. Download this repo anywhere you want (the server will need to write files, so make sure you install in
a location where you have write permission, at least the 'tmp', 'data' and '/www/extracted' folders)
3. Execute 'npm install', this command will download and install the required node modules automatically for you.
```
npm install
```
4. Install your credential keys:
Use system environment variables (This is actually the option you need to use for the tests suite
which runs on [Travis-CI](https://travis-ci.org/)). Replace keys placeholder xxx with your own keys.
* Windows
```
set FORGE_CLIENT_ID=xxx
set FORGE_CLIENT_SECRET=xxx
set FORGE_CALLBACK=xxx
[set PORT=]
node start.js
```
* OSX/Linux
```
[sudo] [PORT=] FORGE_CLIENT_ID=xxx FORGE_CLIENT_SECRET=xxx FORGE_CALLBACK=xxx node start.js
```
Note: the port argument can be omitted and default to port 80. If port 80 is already in use by another
application (like Skype, or IIS, or Apache, ...), you can use any other free port such as 8000, 3000, etc...
But in the next section you would need to specify the port to use, i.e. http://localhost[:port]/
1. Get resources from your file
```
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/load
```
Note the server, use a 2 legged definition by default, but you can override the Authorization by adding an header to the request in order to use your own.
```
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/load -H "Authorization: Bearer ey9f...ks7A"
```
2. Verify resources are ready
```
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/load/progress
```
3. Get IDs and ExternalIDs
```
# Get the highest ID
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/range
# Get all externalIDs
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/*
# Get externalIDs for 1 object with Id == 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1789
# Get externalIDs for several objects with Id == 1066, 1515, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1066,1515,1789
# Get externalIDs for group of objects with Id between 1515 and 1531
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1515-1531
# Get externalIDs for group of objects with Id between 1515 and 1531 and few other objects with Id == 1066, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/ids/1066,1515-1531,1789
```
4. Get properties
```
# Get all properties
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/*
# Get properties for 1 object with Id == 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1789
# Get properties for several objects with Id == 1066, 1515, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1066,1515,1789
# Get properties for group of objects with Id between 1515 and 1531
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1515-1531
# Get properties for group of objects with Id between 1515 and 1531 and few other objects with Id == 1066, 1789
curl -X GET http://localhost:3000/data/dXJuO...Lm53ZA/properties/1066,1515-1531,1789
```
Note you can add the -H "Accept-Encoding: gzip" or -H "Accept-Encoding: deflate" or -H "Accept-Encoding: gzip, deflate" to compress the JSON reply.
4. Free the resources if you do not need it any more
```
curl -X DELETE http://localhost:3000/data/dXJuO...Lm53ZA
```
### BIM360docs and 3legged support
The only time you need a different token than the one generated and used by the server is when you want to access a database coming from a file stored on BIM360docs / Fusion360. In this case, you need a 3legged token which requires you to log with a user credentials. You can get teh token from your application or get help from this server as long you provisionned your keys on the service.
This is where you need to define the FORGE_CALLBACK environment variable, and in your browser go to http://localhost:3000/3legged. After the login process, you should see an access_token on the page you can use to load the database resource on the propertyServer.
--------
## License
This sample is licensed under the terms of the [MIT License](http://opensource.org/licenses/MIT).
Please see the [LICENSE](LICENSE) file for full details.
## Written by
Cyrille Fauvel
Forge Partner Development
http://developer.autodesk.com/
http://around-the-corner.typepad.com