Integrating with HOOPS Publish

(Page 2 of 2)


Exporting to HTML

In Visualize, there are two ways to export to HTML, either through the HTML sprocket or through the Publish sprocket. With the Publish sprocket, it's possible to import a CADModel from the Exchange sprocket; this offers a performance benefit because the model data can be read directly from the PRC created in Exchange without incurring the overhead needed for data conversion.

(Please note, the Publish HTML export feature is only available for 64-bit versions of the Visualize API, and a HOOPS Exchange license is necessary to import files with the Exchange sprocket.)

To export your CAD model to HTML, first import it via the Exchange sprocket:

Exchange::ImportNotifier notifier;
Exchange::ImportOptionsKit importOptions = Exchange::ImportOptionsKit::GetDefault();
importOptions.SetBRepMode(Exchange::BRepMode::BRepAndTessellation);
notifier = Exchange::File::Import(myCADFilePath, importOptions);
notifier.Wait();
if (notifier.Status() != IOResult::Success)
{
// something went wrong with the file import
}
CADModel _cadModel = notifier.GetCADModel();
try
{
Publish::File::ExportHTML(_cadModel, exportedHTMLFilePath, htmlTemplateFilePath, true);
}
catch (IOException const &)
{
// something went wrong with the HTML export
}
Exchange.ImportNotifier notifier;
Exchange.ImportOptionsKit importOptions = Exchange.ImportOptionsKit.GetDefault();
importOptions.SetBRepMode(Exchange.BRepMode.BRepAndTessellation);
notifier = Exchange.File.Import(myCADFilePath, importOptions);
notifier.Wait();
if (notifier.Status() != IOResult.Success)
{
// something went wrong with the file import
}
HPS.CADModel _cadModel = notifier.GetCADModel();
try
{
Publish.File.ExportHTML(_cadModel, exportedHTMLFilePath, htmlTemplateFilePath, true);
}
catch (IOException)
{
// something went wrong with the HTML export
}



Once the import has completed, set a new CADModel object to the CADModel retrieved from the import notifier. Then call Publish::File::ExportHTML() with your CADModel object, the output file path, and the HTML template file.

For your convenience, there are two template files in the Visualize package, HOOPSCommunicatorTemplate.html and HOOPSCommunicatorMinimalTemplate.html. The standard template includes advanced UI features, whereas the minimal template only includes the basic functionality for viewing a model.

For more information on modifying an HTML template file, please see Modifying the HTML Template.