QueryAPI#

Interface QueryAPI

With the Query API you can access additional information about nodes.

  1. Query Object Structure

    The query object is a JSON object which contains a select and a conditions block. The select block is an array which defines the content and layout of the result. The conditions describe a set of tests on nodes and their properties. The result will contain information for all elements on which all conditions passed (implicit AND relation between condition array elements)

    {
    select: [ , <selectkey.value> ]
    conditions: [{:, :}]
    }


  2. Select Keys

    Key Value Example Description
    nodeId number 42 The id of an aux or structure node.
    property any "label" The name of the property to check. If the property is a structure the sub-elements can be accessed with ".". If no condition is set, the node is selected if the property has a non-empty value.
    metadata any "auxAttributes.productionClass", "auxProperties.lowerTolerance" The name of the property to check. If the property is a structure the sub-elements can be accessed with ".". If no condition is set, the node is selected if the property has a non-empty value.
    nodeType string "structure", "aux" Check if the node belongs to a specific class.
    topoHandle json object { "entityID": 1583, "entityType": 1, "shapeInstanceID": 1 } An object that identifies one topological element. Topological elements can be faces edges or points. The elementtype is identified by entityType which can be one of the following values: 1->face 2->edge 3->point Note: This key is only used for the select part of the query as it is resolved to its specialization when returned.
    faceHandle json object { "entityID": 1583, "entityType": 1, "shapeInstanceID": 1 } An object that identifies a topological element of type face.
    edgeHandle json object { "entityID": 1583, "entityType": 2, "shapeInstanceID": 1 } An object that identifies a topological element of type edge.
    pointHandle json object { "entityID": 1583, "entityType": 3, "shapeInstanceID": 1 } An object that identifies a topological element of type point.

  3. Conditions

    Key Value Example Description
    equals any "myLabel", "Label_*" Check whether the selected property equals the set value. Can contain * for arbitrary characters and whitespaces for basic wildcard matching.
    lessThan number 5 Test if the property value is larger than the specified value.
    lessOrEqualThan number 4 Test if the property value is larger or equal than the specified value.
    greaterThan number 10 Test if the property value is smaller than the specified value.
    greaterOrEqualThan number 11 Test if the property value is smaller than the specified value.
    caseSensitive boolean true Default is false.
    pointsTo number 123 Is used to query aux to aux relations (see example).

  4. Logical Keys

    Logical keys can be put inside conditions instead of a select or condition key in order to express the corresponding logical operation.

    Key Value Example Description
    or array {"or": [{"nodeId": 15}, {"nodeId": 16}]} an OR relation
    and array {"and": [{"metadata": "auxProperties.sizeA", "equals": 15}, {"metadata": "auxProperties.sizeB", "equals": 20}]} an AND relation
    not condition {"not": {"metadata": "sizeA", "equals": 15}} invert a condition

  5. Results

    An array of arrays. For each successful condition match an array with the selected element values is returned. The order of values matches the select Specification.

    Select Result
    select: ["nodeId", "metadata.auxAttributes"] [[15, {...}], [42, {...}], ...]

  6. Examples

    Description Query Response
    Aux nodes for a faceHandle excluding nodes of type Revision index { "select": [ "nodeId" ], "conditions": [ { "nodeType": "aux" }, { "faceHandle": { "entityType": 1, "shapeInstanceID": 2, "entityID": 814 } }, { "not": [ { "metadata": "auxProperties.pmiType", "equals": "Revision Index" } ] } ] } [ [ { "entityID": 1583, "entityType": 1, "shapeInstanceID": 1 } ] ]
    Select topological elements connected to one auxNode { "select": [ "topoHandle" ], "conditions": [ { "nodeType": "aux" }, { "nodeId": 2502 } ] } [ [ { "entityID": 1583, "entityType": 2, "shapeInstanceID": 1 } ], [ { "entityID": 1584, "entityType": 1, "shapeInstanceID": 1 } ] ]
    Search metadata for minimum diameter { "select":["nodeId", "metadata.auxProperties.label"], "conditions":[ {"nodeType": "aux"}, {"metadata": "auxProperties.pmiType", "equals": "Dimension"}, {"metadata": "auxProperties.type", "equals": "Diameter"}, {"metadata": "auxProperties.value", "greaterThan": 5.5} ] } [[15, "labelA"], [42, "labelB"], ...]
    Textual search for modelView names { "select": [ "nodeId", "metadata.auxProperties.label" ], "conditions": [ { "nodeType": "aux" }, { "metadata": "auxProperties.pmiType", "equals": "ModelView" }, { "metadata": "auxProperties.label", "equals": "2_51_*" } ] } [ [ 8672, "2_51_Test_2_3" ] ]
    Search for PMI Type { "select": [ "nodeId", "metadata.auxProperties.*" ], "conditions": [ { "nodeType": "aux" }, { "metadata": "auxProperties.pmiType", "equals": "Dimension" }, { "metadata": "auxProperties.fit", "equals": "h8", "caseSensitive": true } ] } [ [ 5411, { "metadata.auxProperties.bottomRight": "0.0640887 0 -0.0686957", "metadata.auxProperties.type": "Linear", ... } ] ]
    Search for attributes { "select":["nodeId"], "conditions":[ {"nodeType": "aux"}, {"metadata": "auxAttributes.precision", "greaterThan": 2}, {"metadata": "auxAttributes.originAnchor", "equals": 4}, ] } [[15], [42], ...]
    Nested query example { "select": [ "nodeId", "metadata.auxAttributes.label" ], "conditions": [ { "nodeType": "aux" }, { "metadata": "auxProperties.pmiType", "equals": "DatumFeatureSymbol" }, { "metadata": "auxAttributes.label", "equals": { "select": [ "metadata.auxProperties.propertyName" ], "conditions": [ { "nodeType": "aux" }, { "metadata": "auxProperties.pmiType", "equals": "frame" }, { "nodeId": 7522 } ] } } ] } [ [ 1234, "abc" ], ..... ]
    Query auxNodes of type ModelView connected to specific auxNode { "select": [ "nodeId" ], "conditions": [ { "nodeType": "aux" }, { "metadata": "auxProperties.pmiType", "equals": "ModelView" }, { "pointsTo": 323 } ] [ [ 1234 ], [ 3456 ], ..... ]


  7. Full Example



    const queryLabels = await context.query({ select: ['nodeId', 'label'], conditions: [{ nodeType: 'aux' }, { metadata: 'auxProperties.pmiType', equals: 'ModelView' }] }); const queryPMIType = await context.query({ select: ['nodeId', 'auxProperties.pmiType'], conditions: [{ nodeType: 'aux' }, { metadata: 'auxProperties.pmiType', equals: 'ModelView' }] });

Hierarchy

Methods

Methods

  • Executes the query on the specified subtree

    Parameters

    • query: string | Query
    • Optional nodeID: number

    Returns Promise<QueryResult>


Did you find this page useful? Please give it a rating:
Thank you for rating this page!
Any issues or feedback?
What kind of problem would you like to report?
Please tell us more about what's wrong: