2. Quick Start

Summary

In this section we'll show you how to view the sample models, and easily convert and view your own CAD models with HC.

Concepts

Prerequisite


Viewing the Sample Page

A web page containing sample models has been provided to allow you to quickly get started. To prepare for viewing the page, navigate to the quick_start directory, ensure that you have Admin privileges, and run start_server.bat/sh (Windows/Linux) to deply the HOOPS Server on your local machine. This will start a local Node.js server that is included with the HOOPS Communicator installer. It will also start instance of the Stream Cache Server, which will stream converted CAD models via WebSocket connections.

Now open http://localhost:11180/index.html in your browser to check out a variety of sample models, as well as examples highlighting the functionality of the Web Viewer API. You can find the source code for these examples in the web_viewer\examples directory of the package.

You can also convert your own CAD models simply by dragging them on convert_file.bat/sh in the quick_start directory (ensure the directory has write privileges). If the HOOPS server is running, those models will be automatically displayed by your default web browser after conversion. You can also get a list of all converted models by opening the converted_files.html document from the quick_start directory in the browser. The converted_files.html document is created when converting your first model using the convert_file.bat/sh batch file.

The convert_file batch file starts a python script that runs an application called "converter" ("converter.exe" on Windows) with some predefined settings, which handles the conversion of the CAD files to the "Stream Cache" format (SC). The SC format is the streaming-optimized internal format that the Web Viewer component can parse. See the Programming Guide for more information on the SC format, and the various loading modes of the Web Viewer component.

For the rest of the tutorial, we will be working with the SCS variant of the SC format. This file type can only be used with a standard web-server and is not compatible with the websocket based streaming or the server-side rendering of the Stream Cache Server.

After the conversion process has finished you can find the resulting .scz file in the \quick_start\converted_models\user\sc_models directory. Additionally, a .scs converted model is also generated and placed into the \quick_start\converted_models\user\scs_models directory and an image of the model is created in the \quick_start\converted_models\user\images directory.

Converting a Model

The easiest way to test Converter more directly and play around with its various settings yourself is to navigate to the authoring\converter\example directory. In there, you'll find the sample.bat/sh (Windows / Linux) script that demonstrates various CAD conversion scenarios.

Let's modify sample.bat/sh (Windows / Linux) to perform your own CAD conversion. Open that file in a text editor and remove everything after the first line that calls Converter (please consult License Overview to locate or obtain your license key):

set CONVERTER_LICENSE_KEY="your_license_key"
IF NOT EXIST output mkdir output
..\bin\<platform>\converter --input "_data\moto\_MOTO_X.asm" --output_sc "output\moto" --license %CONVERTER_LICENSE_KEY%

Now, let's modify the command line above to work with your own data and set a few additional parameters:

..\bin\<platform>\converter --input "c:\test\TestModel.CATProduct" --output_scs "..\..\..\quick_start\converted_models\user\scs_models\TestModel.scs" --output_png "C:\test\testimage.png" --output_png_resolution "1024x768" --license %CONVERTER_LICENSE_KEY%

In the example above, we are specifying an absolute path to a CAD file. Please adjust this path to point to a valid model on your hard drive. If you don't have a CAD file available you can find sample models in the HC package at \authoring\converter\example\_data.

We also generate an image file of the default view for this model and add an additional option to specify a custom image size.

The resulting SCS file can be viewed (assuming the HOOPS server is running) by pasting the following URL into your browser.

http://localhost:11180/hoops_web_viewer_sample.html?scs=TestModel.scs

There is a lot more to Converter. Please see the API Reference for more information on its various command line options. Converter is also provided as a C++ library with the same functionality as the standalone executable.