ShapeSearchBuilder Class — NXOpen Python API Reference 12.0.0 documentation

# ShapeSearchBuilder Class

class `NXOpen.ShapeSearch.``ShapeSearchBuilder`

  Bases: `NXOpen.Builder`

  This class provides the methods to execute shape search and get the searched results.

  The operation that this builder supports has three types: (set by `ShapeSearch.ShapeSearchBuilder.SearchType()`)

  > 1. Search by attributes.

  > > - `ShapeSearch.ShapeSearchBuilder.SetInputAttributesName()`
  > > - `ShapeSearch.ShapeSearchBuilder.SetInputAttributesFilter()`

  > 1. Search by body combined attributes with shape similarity and shape size condition. Support multiple bodies.

  > > - `ShapeSearch.ShapeSearchBuilder.InputBody()`
  > > - `ShapeSearch.ShapeSearchBuilder.SetInputAttributesName()`
  > > - `ShapeSearch.ShapeSearchBuilder.SetInputAttributesFilter()`
  > > - `ShapeSearch.ShapeSearchBuilder.SearchShapeSimilarity()`
  > > - `ShapeSearch.ShapeSearchBuilder.SearchShapeSize()`
  > > - `ShapeSearch.ShapeSearchBuilder.UseCustomShapeSize()`
  > > - `ShapeSearch.ShapeSearchBuilder.CustomShapeSizeLowerLimit()`
  > > - `ShapeSearch.ShapeSearchBuilder.CustomShapeSizeUpperLimit()`

  > 1. Search by part combined attributes with shape similarity and shape size condition. Support loaded part, OS part, Teamcenter part and component.

  > > - `ShapeSearch.ShapeSearchBuilder.InputPart()`
  > > - `ShapeSearch.ShapeSearchBuilder.SetInputAttributesName()`
  > > - `ShapeSearch.ShapeSearchBuilder.SetInputAttributesFilter()`
  > > - `ShapeSearch.ShapeSearchBuilder.ReferenceSetName()`
  > > - `ShapeSearch.ShapeSearchBuilder.SearchShapeSimilarity()`
  > > - `ShapeSearch.ShapeSearchBuilder.SearchShapeSize()`
  > > - `ShapeSearch.ShapeSearchBuilder.UseCustomShapeSize()`
  > > - `ShapeSearch.ShapeSearchBuilder.CustomShapeSizeLowerLimit()`
  > > - `ShapeSearch.ShapeSearchBuilder.CustomShapeSizeUpperLimit()`

  When initialize builder, we will load all saved searches from work directory and add them to search list. You can implement `ShapeSearch.ShapeSearchBuilder.ExecuteSearch()` to run the saved search.

  After define the search criteria, function `ShapeSearch.ShapeSearchBuilder.ExecuteSearch()` can search the shape from database and return the searched results count and error message if fails. The search is specified by ‘searchName’ parameter.

  The method `ShapeSearch.ShapeSearchBuilder.GetResults()` can get the specified results from database. The range of results is specified by the parameters ‘startResultId’ and ‘endResultId’, the search is specified by ‘searchName’ parameter.

  The method `ShapeSearch.ShapeSearchBuilder.OpenResultPart()` can open the selected result part of the specified search. The result is specified by ‘resultId’ parameter, the search is specified by ‘searchName’ parameter.

  To create a new instance of this class, use `NXOpen.ShapeSearch.SearchManager.CreateShapeSearchBuilder()`

  New in version NX6.0.0.

# Properties

Property | Description
--- | ---
CustomShapeSizeLowerLimit | Returns or sets the custom shape size lower limit to be set for search.
CustomShapeSizeUpperLimit | Returns or sets the custom shape size upper limit to be set for search.
InputBody | Returns the input body to be searched
InputPart | Returns or sets the input part to be searched
ReferenceSetName | Returns or sets the part reference set name to be set for search
SearchShapeSimilarity | Returns or sets the shape similarity to be set for search
SearchShapeSize | Returns or sets the shape size to be set for search.
SearchType | Returns or sets the search type
Tag | Returns the Tag for this object.
UseCustomShapeSize | Returns or sets the use custom shape size to control use shape size option or custom shape size

# Methods

Method | Description
--- | ---
Commit | Commits any edits that have been applied to the builder.
Destroy | Deletes the builder, and cleans up any objects created by the builder.
ExecuteSearch | Execute new search or saved search and output error message if error.
GetCommittedObjects | For builders that create more than one object, this method returns the objects that are created by commit.
GetInputAttributesFilter | The input attributes filter to be searched
GetInputAttributesName | The input attributes name to be searched
GetObject | Returns the object currently being edited by this builder.
GetResults | Get specified search results from database.
OpenResultPart | Open the searched result part.
SetInputAttributesFilter | The input attributes filter to be searched
SetInputAttributesName | The input attributes name to be searched
ShowResults | Updates the model to reflect the result of an edit to the model for all builders that support showing results.
Validate | Validate whether the inputs to the component are sufficient for commit to be called.

# Enumerations

ShapeSearchBuilderOpenPartType Enumeration | The open part type enum
ShapeSearchBuilderSearchByType Enumeration | The search type enum
ShapeSearchBuilderShapeSimilarity Enumeration | The search shape similarity enum
ShapeSearchBuilderShapeSize Enumeration | The search shape size enum

# Property Detail

## CustomShapeSizeLowerLimit

`ShapeSearchBuilder.``CustomShapeSizeLowerLimit`

  Returns or sets the custom shape size lower limit to be set for search.

  It is used only when use custom shape size is true. It must be greater than zero and less than upper limit.

  `-------------------------------------`

  Getter Method

  Signature `CustomShapeSizeLowerLimit`

  Returns: |
  Return type: | int

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `CustomShapeSizeLowerLimit`

  Parameters: | customShapeSizeLowerLimit (int) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## CustomShapeSizeUpperLimit

`ShapeSearchBuilder.``CustomShapeSizeUpperLimit`

  Returns or sets the custom shape size upper limit to be set for search.

  It is used only when use custom shape size is true. It must be greater than lower limit.

  `-------------------------------------`

  Getter Method

  Signature `CustomShapeSizeUpperLimit`

  Returns: |
  Return type: | int

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `CustomShapeSizeUpperLimit`

  Parameters: | customShapeSizeUpperLimit (int) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## InputBody

`ShapeSearchBuilder.``InputBody`

  Returns the input body to be searched

  `-------------------------------------`

  Getter Method

  Signature `InputBody`

  Returns: |
  Return type: | `NXOpen.SelectNXObjectList`

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## InputPart

`ShapeSearchBuilder.``InputPart`

  Returns or sets the input part to be searched

  `-------------------------------------`

  Getter Method

  Signature `InputPart`

  Returns: |
  Return type: | str

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `InputPart`

  Parameters: | inputPart (str) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## ReferenceSetName

`ShapeSearchBuilder.``ReferenceSetName`

  Returns or sets the part reference set name to be set for search

  `-------------------------------------`

  Getter Method

  Signature `ReferenceSetName`

  Returns: |
  Return type: | str

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `ReferenceSetName`

  Parameters: | referenceSetName (str) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## SearchShapeSimilarity

`ShapeSearchBuilder.``SearchShapeSimilarity`

  Returns or sets the shape similarity to be set for search

  `-------------------------------------`

  Getter Method

  Signature `SearchShapeSimilarity`

  Returns: |
  Return type: | `NXOpen.ShapeSearch.ShapeSearchBuilderShapeSimilarity`

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `SearchShapeSimilarity`

  Parameters: | searchShapeSimilarity (`NXOpen.ShapeSearch.ShapeSearchBuilderShapeSimilarity`) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## SearchShapeSize

`ShapeSearchBuilder.``SearchShapeSize`

  Returns or sets the shape size to be set for search.

  It is used only when use custom shape size is false.

  `-------------------------------------`

  Getter Method

  Signature `SearchShapeSize`

  Returns: |
  Return type: | `NXOpen.ShapeSearch.ShapeSearchBuilderShapeSize`

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `SearchShapeSize`

  Parameters: | searchShapeSize (`NXOpen.ShapeSearch.ShapeSearchBuilderShapeSize`) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## SearchType

`ShapeSearchBuilder.``SearchType`

  Returns or sets the search type

  `-------------------------------------`

  Getter Method

  Signature `SearchType`

  Returns: |
  Return type: | `NXOpen.ShapeSearch.ShapeSearchBuilderSearchByType`

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `SearchType`

  Parameters: | searchType (`NXOpen.ShapeSearch.ShapeSearchBuilderSearchByType`) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## UseCustomShapeSize

`ShapeSearchBuilder.``UseCustomShapeSize`

  Returns or sets the use custom shape size to control use shape size option or custom shape size

  `-------------------------------------`

  Getter Method

  Signature `UseCustomShapeSize`

  Returns: |
  Return type: | bool

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

  `-------------------------------------`

  Setter Method

  Signature `UseCustomShapeSize`

  Parameters: | useCustomShapeSize (bool) –

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

# Method Detail

## ExecuteSearch

`ShapeSearchBuilder.``ExecuteSearch`

  Execute new search or saved search and output error message if error.

  Signature `ExecuteSearch(isNew, searchName)`

  Parameters:

  - isNew (bool) – True is executing new search, False is executing saved search
  - searchName (str) – Search name

  Returns: | a tuple
  Return type: | A tuple consisting of (nTotalResults, errorMessage) nTotalResults is a int. Search result total number errorMessage is a str. Search error message

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## GetInputAttributesFilter

`ShapeSearchBuilder.``GetInputAttributesFilter`

  The input attributes filter to be searched

  Signature `GetInputAttributesFilter()`

  Returns: |
  Return type: | list of str

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## GetInputAttributesName

`ShapeSearchBuilder.``GetInputAttributesName`

  The input attributes name to be searched

  Signature `GetInputAttributesName()`

  Returns: |
  Return type: | list of str

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## GetResults

`ShapeSearchBuilder.``GetResults`

  Get specified search results from database.

  Signature `GetResults(searchName, startResultId, endResultId)`

  Parameters:

  - searchName (str) – Search name
  - startResultId (int) – Start result id
  - endResultId (int) – End result id

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## OpenResultPart

`ShapeSearchBuilder.``OpenResultPart`

  Open the searched result part.

  Signature `OpenResultPart(openPartType, searchName, resultId)`

  Parameters:

  - openPartType (`NXOpen.ShapeSearch.ShapeSearchBuilderOpenPartType`) – Open part type
  - searchName (str) – Search name
  - resultId (int) – Result id

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## SetInputAttributesFilter

`ShapeSearchBuilder.``SetInputAttributesFilter`

  The input attributes filter to be searched

  Signature `SetInputAttributesFilter(inputAttributesFilter)`

  Parameters: | inputAttributesFilter (list of str) – Search attributes filter

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## SetInputAttributesName

`ShapeSearchBuilder.``SetInputAttributesName`

  The input attributes name to be searched

  Signature `SetInputAttributesName(inputAttributesName)`

  Parameters: | inputAttributesName (list of str) – Search attributes Name

  New in version NX6.0.0.

  License requirements: shape_search (“Shape Search”)

## Validate

`ShapeSearchBuilder.``Validate`

  Validate whether the inputs to the component are sufficient for commit to be called.

  If the component is not in a state to commit then an exception is thrown. For example, if the component requires you to set some property, this method will throw an exception if you haven’t set it. This method throws a not-yet-implemented NXException for some components.

  Signature `Validate()`

  Returns: | Was self validation successful
  Return type: | bool

  New in version NX3.0.1.

  License requirements: None.