CADViewer Technical Documentation, Installation Guide and Reference Samples Library

NodeJS

This documents running a standard CADViewer top-level JavaScript instance with the NodeJS conversion server in the same folder tree.

NOTE: There is an alternative encapsulation using CADViewer npm: https://www.npmjs.com/package/cadviewer, with NodeJS backend server: https://github.com/CADViewer/cadviewer-conversion-server, which should be the primary installation when installing CADViewer on ReactJS, Angular and VueJS.

Windows

Windows - Folders

For a CADViewer NodeJS installation on Windows, the base file-structure should be as below:

c:/nodejs
    └─── cadviewer
            ├── app
            │    ├── cv
            │    │    ├── cv-pro 
            │    │    │   ├── menu_config
            │    │    │   ├── language_table
            │    │    │   └── space
            │    │    │         ├── css 
            │    │    │         └── html
            │    │    ├── cv-core
            │    │    │   ├── menu_config
            │    │    │   └── language_table
            │    │    └── cv-custom_commands
            │    ├── fonts
            │    ├── images
            │    ├── js
            │    ├── css
            │    └── user_resources	
            ├── converters
            │    ├── ax2020
            │    │     ├── windows 
            │    │     │      └── fonts
            │    │     └── linux
            │    │            └── fonts
            │    ├── dwgmerge2020
            │    │         ├── windows 
            │    │         │      └── fonts
            │    │         └── linux
            │    │            └── fonts
            │    ├── linklist2020
            │    │         ├── windows 
            │    │         │     └── fonts
            │    │         └── linux
            │    │               └── fonts
            │    └── files
            ├── content
            ├── html
            └── temp_print

Note that folders for advanced interaction, such as database connectivity and advanced REST-API connectivity features are not included in this folder tree, please see the Samples section for integration with this type of functionality.

Windows - Configuration

In folder:

c:/nodejs
    └─── cadviewer

locate the configuration file: CADViewer_config.json , edit the settings to reflect your installation. Note that, in this setup is assuming the front-end server with the CADViewer html file to have the ServerFrontEndUrl and the conversion server to have the ServerUrl settings.

Windows - HTML

In folder:

c:/nodejs
    └─── cadviewer
            └── html

Identify your sample mysample.html file, and ensure that it properly set the Url to the front-end, back-end and server paths (this can be hidden by using “getServerLocationFromScript”.

Windows - Install request

Install the request package to handle load of external http/https drawaings:

> npm i request

Windows - Run Server

Run the Back-End server from the location of the installation, C:\nodejs\cadviewer:

C:\nodejs\cadviewer>node CV_6.X.YY.js
http://127.0.0.1:3000
http://127.0.0.1:8081
getFile_09
true
CADViewer Server is listening on port 3000!
Server running at http://127.0.1.1:3000/

Run the server serving the Front-End from the location of the installation, C:\nodejs\cadviewer:

C:\nodejs\cadviewer>npx http-server
npx: installed 26 in 4.196s
Starting up http-server, serving ./
Available on:
  http://192.168.1.135:8081
  http://178.30.104.178:8081
  http://127.0.0.1:8081
Hit CTRL-C to stop the server

Alternatively, if npx is not installed, use npm to install a http server globally, and then run the Front-End server specifically on port 8081, from the location of the installation C:\nodejs\cadviewer:

C:\nodejs\cadviewer>npm install http-server -g
C:\nodejs\cadviewer>http-server -p 8081
Starting up http-server, serving ./
Available on:
  http://79.102.163.72:8081
  http://127.0.0.1:8081
Hit CTRL-C to stop the server

Open a web-browser pointing to your sample html file: http:/127.0.0.1/8081/html/mysample.html

Use the server traces and browser development console for debugging, alternatively contact our Support

Linux

Linux - Folders

On Linux a NodeJS server can be launched from any location, a CADViewer NodeJS installation on Linux, the suggested base file-structure under user structure should be as below:

/usr/bin
    └─── cadviewer
            ├── app
            │    ├── cv
            │    │    ├── cv-pro 
            │    │    │   ├── menu_config
            │    │    │   ├── language_table
            │    │    │   └── space
            │    │    │         ├── css 
            │    │    │         └── html
            │    │    ├── cv-core
            │    │    │   ├── menu_config
            │    │    │   └── language_table
            │    │    └── cv-custom_commands
            │    ├── fonts
            │    ├── images
            │    ├── js
            │    ├── css
            │    └── user_resources	
            ├── converters
            │    ├── ax2020
            │    │     ├── windows 
            │    │     │      └── fonts
            │    │     └── linux
            │    │            └── fonts
            │    ├── dwgmerge2020
            │    │         ├── windows 
            │    │         │      └── fonts
            │    │         └── linux
            │    │            └── fonts
            │    ├── linklist2020
            │    │         ├── windows 
            │    │         │     └── fonts
            │    │         └── linux
            │    │               └── fonts
            │    └── files
            ├── content
            ├── html
            └── temp_print

Note that folders for advanced interaction, such as database connectivity and advanced REST-API connectivity features are not included in this folder tree, please see the Samples section for integration with this type of functionality.

Linux - Configuration

In folder:

/usr/bin
    └─── cadviewer

locate the configuration file: CADViewer_config.json , edit the settings to reflect your installation. Note that, in this setup is assuming the front-end server with the CADViewer html file to have the ServerFrontEndUrl and the conversion server to have the ServerUrl settings.

Linux - HTML

In folder:

/usr/bin
    └─── cadviewer
              └── html

Identify your sample mysample.html file, and ensure that it properly set the Url to the front-end, back-end and server paths (this can be hidden by using “getServerLocationFromScript”.

Linux - Permissions

In folder:

/usr/bin
    └─── cadviewer
              └── converters
                      └── ax2020
                             └── linux

Ensure that the executable has chmod 777 permissions.

Windows - Install request

Install the request package to handle load of external http/https drawaings:

> npm i request

Linux - Run Server

Run the Back-End server from the location of the installation, /usr/bin/cadviewer:

user@user-VirtualBox:~$ pwd
/usr/bin/cadviewer
user@user-VirtualBox:~$ node CV_6_X_YY.js
http://127.0.0.1:3000
http://127.0.0.1:8081
getFile_09
true
CADViewer Server is listening on port 3000!
Server running at http://127.0.1.1:3000/

Run the server serving the Front-End from the location of the cadviewer installation, /usr/bin/cadviewer, for example use npm:

user@user-VirtualBox:~$ pwd
/usr/bin/cadviewer
user@user-VirtualBox:~$ sudo npm install http-server -g
user@user-VirtualBox:~$ http-server -p 8080
Starting up http-server, serving ./
Available on:
  http://127.0.0.1:8080
  http://10.0.2.15:8080
Hit CTRL-C to stop the server

Open a web-browser pointing to your sample html file: http:/127.0.0.1/8080/html/mysample.html

Use the server traces and browser development console for debugging, alternatively contact our Support

Troubleshooting

One issue that often appears in installations is that interface icons do not display properly:

Icons

Typically the variable ServerUrl or ServerBackEndUrl is not set to reflect the front-end server url or port.



Server Source Code - Windows and Linux

The NodeJS server code is similar on Windows and Linux, the latest version is CV_6.X.YY.js .

Application programmers may modify content to integrate with their own software or application.

Use the following Github link: https://github.com/CADViewer/cadviewer-conversion-server

Last updated on 25 Sep 2020
Published on 13 Mar 2020