Processing Query Results
Copy
Processing the query results entails extracting the information necessary to construct the Product Occurrences as well as any additional information that will be used in constructing Rendering Configurations. At a minimum, the following is needed:
- ID and name of whatever element represents the 3D Geometry in the Tree Grid View.
- ID of the Query Reference that corresponds to the row in the Tree Grid View that the geometry will map to when selected in the viewer.
- BOM hierarchy of elements.
- Transformation matrices for each Instance of 3D Geometry.
- ID of the view file used for each 3D geometry component.
In this example, the element representing 3D Geometry is the CAD Item. Note that this could be a Part Item, or some other custom Item used in the data model. It represents the node that is selected in the Tree Grid View when the 3D component geometry is selected in the 3D View. The hierarchy of 3D Components is also important since transformations are applied top-down. In the default CAD Data model in Aras Innovator, Child CAD Items are transformed relative to the transformation applied to their parent CAD Item, and so on. Transformations are required to position the instance of the 3D geometry in 3D space. Finally, the ID of the view file uniquely identifies the view file in the Aras Innovator Vault.
The Default CAD Query Definition will return one or more root CAD Items, which represents the CAD Item the Query Definition was executed against along with any additional CAD Items selected using Digital Mockup (see Section 0). Each of these CAD Items should contain the same Properties so processing the full CAD Hierarchy can be done recursively. For each CAD Item parsed from the Query Execution results, a single CAD Item Data Object is created.
In this example, and in Figure 54, the CAD Class is used to process the data from the Query Execution results and store the data identified above. For each instance parsed, the transformation string is extracted and stored as a String within a list. The number of transformation strings in this list represent the number of instances of the current CAD Item relative to its parent CAD Item. Bounding box data, if present, is collected in a simple struct with double attributes for each X/Y/Z min and max values.
If a given CAD Item is an assembly, it should contain child CAD Items. In this case, each of those CAD items are processed recursively down to the component CAD Item. Component CAD Items need to parse the associated view file data. Only view files for Component (NOT Assembly) CAD Items should be included in the Product Occurrences. The following is a code snippet showing a possible implementation of processing CAD Item Data:
internal void processCAD(QueryBuilderNode qbItem) { QryRefId = qbItem.QueryItem.RefId; // Query Item Reference ID try { ID = qbItem.GetProperty(“id”); // required Name = qbItem.GetProperty(“name”); // required } catch { throw new ArgumentException(“Query Definition is not defined properly: ‘id’ and ‘name’ Properties are required for CAD Items”); } // Bounding Box Data. Alternate values ensure that there is a non-empty // bounding volume defined // NOTE: Bounding box data should first be retrieved from the related CAD ConversionInfo Relationship. If not present, retrieve from the CAD Item directly _BBox.MinX = _getPropertyAsDouble(qbItem, “x_min”, -1.0); _BBox.MaxX = _getPropertyAsDouble(qbItem, “x_max”, 1.0); _BBox.MinY = _getPropertyAsDouble(qbItem, “y_min”, -1.0); _BBox.MaxY = _getPropertyAsDouble(qbItem, “y_max”, 1.0); _BBox.MinZ = _getPropertyAsDouble(qbItem, “z_min”, -1.0); _BBox.MaxZ = _getPropertyAsDouble(qbItem, “z_max”, 1.0); // for processing CAD children and associated view file foreach (var child in qbItem.ChildNodes) { if (child.QueryItem.Alias == “CAD ConversionInfo”) _processCADConversionInfo(child); if (child.QueryItem.Alias == “CAD Structure”) _processCADStructure(child); if (child.QueryItem.Alias == “File”) _extractFileInfo(child); } // foreach } // processCAD(QueryBuilderNode qbItem) In this sample, the method assumes the type of Query Node provided refers to a CAD ItemType. In the Default Query Definition, CAD Items include Properties for each Property and Child Nodes for related Files and CAD Structure. Note that the Properties for ‘id’ and ‘name’ are required and an exception is thrown if they are not found.