27 Oct 2021

Viewing 3D Models on Node-RED platforms

Node-RED

This blog post is extension of https://forge.autodesk.com/blog/forge-node-red-visual-programming-forge 

In this post we will see how to view a 3D model using Forge nodes on Node-RED platform.

Setup

For Windows 

Using cmd: node --version && npm --version

You should receive back output that looks similar to:

v14.15.1
6.14.8
 
npm install -g --unsafe-perm node-red

Once installed, the simple way to run Node-RED is to use the `node-red` command in a command prompt: If you have installed Node-RED as a global npm package, you can use the node-red command:


C:>node-red

This will output the Node-RED log to the terminal. You must keep the terminal open in order to keep Node-RED running.

Open browser and run http://127.0.0.1:1880

You will see this window.

Node-RED-Welcome-Banner

Note that running Node-RED will create a new folder in your %USERPROFILE% folder called .node-red. This is your userDir folder, think of it as the home folder for Node-RED configuration for the current user. You will often see this referred to as ~/.node-red in documentation. ~ is shorthand for the user home folder on Unix-like systems. You can use the same reference if using PowerShell as your command line as recommended. If you are using the older cmd shell, that won’t work.

Setup Node-Forge

Close the browser or cancel Node server if it is running.

cd %USERPROFILE%\.node-red
npm install node-red-node-forge --save

Viewing The Model

node-red
  • Open browser and run http://127.0.0.1:1880

  • Click on the Hamburger Button on the UI

  • Click on the Import

  • Go to Lib\Flows and Select ViewerFlow.json

Import Viewer Flow

  • After importing the flow, you should see

After Import Flow

Select Dev Credentials

Select DevCreds

  • Select the Hook Model, and edit msg.payload

    with following

    bucket name of your bucket

    key object key

    localFilename valid path of the model file that you would like to view.

        "bucket": "node-red-bucket-viewer",
        "key": "Hook.stp",
        "localFilename": "C:/Users/Madhukar/Documents/Hook.stp",
        "region": "US"
  • Edit all the Hook Model Nodes, and Translate and Wait make sure you select the SVF 2D and 3D view in the MD Translate node.
  • Update all other Nodes with forge-node-viewer-test

Follow this video tutorial for interactive steps.

 

Related Article