Change Background color of 2D sheets of Autodesk Forge using Javascript

619 views Asked by At

How to set a background color in 2D view of autodesk forge file to a specific Room on a floor or level using jquery

1

There are 1 answers

0
michael beale On BEST ANSWER

To set a background color in 2D, you have to two programmable options...

viewer.setBackgroundColor(...); viewerImp.toggleSwapBlackAndWhite(true/false);

You can find the API details for setBackgroundColor here: https://developer.autodesk.com/en/docs/viewer/v2/reference/javascript/viewer3d/

and line2191 toggle blackwhite here: autodeskviewer.com/viewers/latest/docs/src_application_Viewer3D.js.html

Here is a working example...

  1. Open this URL in a recent version of chrome: https://autodeskviewer.com/viewers/latest/viewer3d.html?svf=https://lmv-models.s3.amazonaws.com/2d_model/primaryGraphics.f2d

  2. Open up the debug console and type these two options:

NOP_VIEWER.impl.toggleSwapBlackAndWhite(true); NOP_VIEWER.setBackgroundColor(255,255,0,0,255,255);

The result should give you a clue to what is possible with just the api.

This is specific to the web viewer. Is that what you were looking for ?