The contents of the loaded 3D model (represented with ModelData_Model) can be explored in memory. Depending on an input file format, a 3D model may contain:
- Product structure (or scene graph): a hierarchy of assemblies and parts, and instances thereof;
- Names and appearances (e.g. colors and materials) attached the graph elements;
- User-defined properties (string, integer or double precision numbers, dates, etc);
- Geometrical representations of the parts, for instance, meshes;
- PMI (Product and Manufacturing Information).
The product structure of the loaded 3D file can be explored using the scene graph element visitor. The visitor class which must subclass cadex.ModelData_SceneGraphElementVisitor
and redefine methods visitPart(), visitAssemblyEnter(), visitAssemblyLeave(). The following example demonstrates creation of a custom visitor and applying it to the model:
class SceneGraphVisitor extends cadex.ModelData_SceneGraphElementVisitor {
...
async visitElement(theElement) {
this.info += formatKeyValue('Uuid', theElement.uuid);
this.info += formatKeyValue('Name', theElement.name);
...
}
async visitPart(thePart) {
await this.visitElement(thePart);
...
}
...
}
const aVisitor = new SceneGraphVisitor();
await aModel.accept(aVisitor);
...
In a similar way, parts can be explored for available representations:
class RepresentationVisitor extends cadex.ModelData_RepresentationVisitor {
async visitBRepRepresentation(theBRepRep) {
...
}
async visitPolyRepresentation(thePolyRep) {
...
}
}
const aRepVisitor = new RepresentationVisitor();
await thePart.acceptRepresentationVisitor(aRepVisitor);
...
Refer to the Model explorer example that demonstrates various techniques to retrieve data from the loaded 3D model.