SearchRule

class SearchRule(query: ShapeQuery)

A SearchRule searches for a Shape in a design.

Specifically, given a query u, and design w, it computes the transformations f_i that embed u in w. It then identifies all unique f_i(u) (the symmetry of u and w might result in different transformations creating equivalent f_i(u)) and asks the user to choose a match f_i to select. When the user selects a match, w will be replaced by w - f_i(u), u will be placed on top and then selected (using the CommunicationLayer’s output_shape() method with select=True). If ALL is selected, w is then replaced with w - Σf_i(u) and Σf_i(u) is placed on top and selected. The transformations are computed with the query_transformation’s compute() method.

Parameters:

query – The ShapeQuery to use when searching (u).

Attributes

application_type

The RuleApplicationType to use when selecting a match to apply the rule to.

Methods

apply_to

Apply this Rule to a Shape.

apply_to(shape: Shape, communication_layer: CommunicationLayer, in_automation: bool = False, _to_design: ndarray = array([0., 0., 0.])) Tuple[Rule, List[Tuple[Shape, Shape]], Shape, Shape, Shape, Shape]

Apply this Rule to a Shape.

Parameters:
  • shape – The shape to apply this rule to.

  • communication_layer – The CommunicationLayer to use during rule application.

  • in_automation – Whether this rule is being applied as part of an automation (e.g.: as part of a RuleSequence or Program).

  • _to_design – Vector used to relocate the matches to the design in application previews and enumerations. This is needed because the ShapeMachine engine internally shifts its initial_design to the origin to reduce floating-point error.

Returns:

The shape created as a result of rule application.

application_type

The RuleApplicationType to use when selecting a match to apply the rule to.