Query, Find, and Access Functions

This page discusses:

Feature.Access()

Method used to return an object from a path. You must indicate the location of what you are looking for.

Signature

Feature.Access(Path: String, Type: String) : UndefinedType

Arguments

Name Input / Output Required? Type Comment
Path In Yes String
Type In Yes String

ReturnType

UndefinedType

Feature.Find()

Method used to find an object that is a child or a parent, that is of a given type, and that fulfills a condition. It stops when it finds the first object.

Signature

Feature.Find(Type: String, Condition: String, Down: Boolean) : UndefinedType

Arguments

Name Input / Output Required? Type Comment
Type In Yes String
Condition In Yes String
Down In Yes Boolean Asks if you are interested in the children or the fathers. When going up, the scan stops at the document border. Starting from a mechanical feature, it stops at the PartFeature. Starting from an product instance, it does not go upper than the product that owns it. Starting from a product reference, it means nothing.

When going down, all the children in the tree are scanned and in the case of a product, it crosses the instance/reference border.

ReturnType

UndefinedType

Feature.Query()

Method used to search for the features located below the feature to which it applies and that verifies the specified expression The objects found are added to the list. All the children are scanned, the direct ones and recursively in the tree.

Signature

Feature.Query(Type: String, Condition: String) :
 List

Arguments

Name Input / Output Required? Type Comment
Type In Yes String
Condition In Yes String

ReturnType

List

Example

List.1=PartBody.Query("Hole","x.Diameter>50mm")

In the example above, the result of the search will return the holes of PartBody whose diameters are greater than 50mm. Where:

  • List.1is the name of the list on which the calculation will be performed.
  • PartBodyis the body on which the search will be carried out.
  • Hole is the Type of the searched feature.
  • x.Diameter>50mm is the expression.
Note: Remember that:
  • The expression can be empty.
  • In an assembly context, if you perform a query on a type deriving from the type Product or on a type assigned to a product (such as electrical types for example), the query will return more items than expected because all the product instances (even those that are not visible) are returned as well as their references.