Creating a 3D Model
3D Models can be created either by loading an existing CAD file through the HOOPS Exchange Loader or by authoring a CAD model from scratch using the HOOPS Publish PRC API.
Loading a CAD File
For integration purposes, Publish customers can use one of the following CAD importers:
STEP
JT
Parasolid
ACIS
IFC
VRML
STL
IGES
You’ll typically choose a format that can be exported from your application. For instance, if your application is using Parasolid you’ll be able to create a 3D model from Parasolid files or buffers (in memory). Similarly, if you’re using STEP, you’ll write a STEP file from your application and HOOPS Publish will then import this STEP file.
To import a CAD file, use the HoopsExchangeLoader:
A3DSDKHOOPSExchangeLoader sHoopsExchangeLoader(myFilename);
A3DStatus importResult = sHoopsExchangeLoader.Import(A3DImport(filename));
Creating a CAD Model With the PRC API
HOOPS Publish can also be used to create a CAD model from scratch. For instance, it can be used to create geometry, then faces, parts, assembly nodes, and, finally, a model file.
To author your own 3D models, you’ll first need to understand the PRC data model. To facilitate your understanding of PRC, please read the following sections of the HOOPS Exchange programming guide:
Mixed Mode: Enriching a CAD Model
In some cases, you can use a mixed mode to enrich an imported CAD file. For instance, if you’re using Parasolid or IGES to transfer the assembly tree and the geometry, you could use the PRC API to enrich the imported 3D model with PMI.
First, you’ll need to access the model file pointer for the HOOPS Exchange Loader. This pointer gives you a reference to the root of the assembly tree:
A3DAsmModelFile* myModelPtr = sHoopsExchangeLoader.m_psModelFile;
You will then traverse this model file until you reach the element that needs to be modified.
Please see Reading model geometry in the HOOPS Exchange Programming Guide for more information on how to traverse a model file.
Exporting a CAD Model
Exporting your model is similar to importing – simply reverse the procedure. Three elements are necessary for exporting a CAD model: the model file pointer, the export parameters data structure, and the target filename. The supported export formats can be found here.
To export a model file, use the HOOPSExchangeLoader. Make sure you’ve imported a ModelFile (sHoopsExchangeLoader.psModelFile) and create an Export object with the filename you’d like to use. The export file type is determined by the file extension, so you should use a known file extension for the file format.
A3DExport sExport(exportFilename);
A3DStatus iRet = sHoopsExchangeLoader.Export (sExport);
The export object can be used to define every option available for the format you’re using. For instance:
sExport.m__sExportStepData.m_eStepFormat = kA3DStepAP242;
See the Import/Export sample for more information.