Autodesk’s Forge Viewer is a WebGL-based, JavaScript library for 3D and 2D model rendering. These 3D and 2D data may come from a wide variety of applications such as AutoCAD, Fusion 360, Revit or any other CAD application.
Many industries use this viewer to render the model data in the browser but that needs the model data to be converted into SVF format (a generic format used by forge viewer to render the model data).

Fig. 1: Flowchart describing the flow of conversion

Get started with these quick steps to convert any CAD model Forge viewer compatible

1. Create an App in Forge (Use this link to SignIn/Register https://forge.autodesk.com)


Fig. 2: List of API selection used by the app

Once your app is created successfully it will look like this, note down the client-id and client-secret for the next step

Fig. 3: App information available after successful app creation

2. Generate access-token from client-id and client-secret

To generate access token you will need to use Authentication API of Forge

Fig. 4: Successful access token generation for client_id and client_secret

This access-token will be used by all the operation related to bucket creation, reading bucket, reading bucket’s object data and writing bucket’s object data.

Set this access token in Authorization attribute of header

Fig. 5: Setting up access token in Authorization attribute of header

Access token is set as environment variable in Postman.

3.Create a bucket in forge server

Fig. 6: Successful bucket creation using access-token

4. Upload the model in the Forge bucket

Here I have used .rvt file to upload in Forge bucket you can use any.
Programmatically you can convert the .rvt file content into a byte array and send it in the request body. (You need to set Content-Type as application/octet-stream)

Fig. 7: Successful upload of object(a .rvt file) in forge bucket

After successful upload of the object in the Forge bucket, you need to get the objectId from its response
This objectId needs to be encoded into the Base-64 string.

You can refer to this link https://www.base64encode.org/

5. Translate the model into SVF format (forge viewer renderable format)

This process uses model-derivative API of forge

Fig. 8: Successful creation of translation of object into SVF

After the conversion process is started it continues to run on Forge server. You can track the progress of the conversion as below

Fig. 9: Successful translated CAD model data into SVF

For visualizing the CAD model in Forge viewer I have integrated Forge Extension in Visual Studio Code. You can refer this link https://forge.autodesk.com/blog/forge-visual-studio-code

Fig. 10: Visualising the CAD model data in forge viewer

So we see how simple it is to convert any 3D CAD model Forge viewer renderable. You can integrate Forge viewer in your application and can use language-specific SDK as well for your application.

You can use the POSTMAN import file from here, and don’t forget to set your client-id and client-secret.
https://drive.google.com/open?id=1iflSuvxSVpFacRb42bt4mKJgMwXERIma

Happy coding!!

Author: V. Bhandari
Contact us:
info@prototechsolutions.com
ProtoTech Solutions Pvt Ltd.