Searcher

Searcher is a powerful search tool with such options as:

  • case sensitivity
  • wildcards
  • regular expressions support
  • clean search result representation with Qt table view.
  • extending with your own search types

Just run the tool, type search string, hit Enter and you will get results looking something like this.

fxs_result

Interface.

fxs_search_type_buttons

On the right side you can see search type buttons. If pressed, this type of search is active, and if result of that particular search type is not empty, a tab with results will appear in main area.

At top right corner there are search options buttons:
Aa – if on, search will be case sensitive
Re – enable it to treat search string es RegEx
Sel – select all search results immediately.
Sh – include shapes in search. By default shapes are ignored in search. Enable it to treat shapes as regular nodes.
SS – search only in selected nodes.

Extending

The most important feature is that you can easily extend Searcher with your own custom search types. Moreover you can display as much information in result table as you want. Also, it is up to you what node or nodes Searcher must select if you select one or more results in results table. For example, if you use Textured By search type and then will click on results, instead of selecting file nodes Searcher will select geometry textured with this file node.

What you need to add your search type.

First of all visit Searchers.py and inherit a new class from SearcherBase
Then you need to implement 3 methods.

getColumnNames

It is the simplest one. Just return column names you want to see in results table

gatherSearchData

here you must return list of tuples in form of
[(fullPathName, searchField), (fullPathName, searchField), ...]
where fullPathName – full Maya path to node and searchField – is a string on which a search procedure will be performed. For example in SearcherTextures class (finding a file node based on texture name) fullPathName is name of file node, and searchField is the value of .fileTextureName attribute (i.e. texture path on disk)

prepareModelData

matchedData argument of this method is a list of tuples in the same form as return value of gatherSearchData
[(fullPathName, searchField), (fullPathName, searchField), ...]
but in this case it contains data that matched by search criteria. The main purpose of this method is to return all data needed for results table. This method also must return a list of tuples. The first elements of these tuples must contain strings corresponding to columns you’ve defined in getColumnNames. The last element must be instance of special class called NodeInfo. It is a simple class containing only three fields:

  • selectionString – a list of strings, full Maya path names of objects that will be selected when you select this result in results table
  • fullPathName – same as fullPathName in matchedData argument
  • shortName – short Maya name of fullPathName

So in case of SearcherTextures result list must be
[(fileNodeName, textureShortName, fileNodeTexturePath, nodeInfo), ...]

Register Searcher

The last thing you need to do is to visit fx_search.py and add your searcher to self.searchers list located in initSearchersAndControls method.

Installation

Search is a part of FX Python Tools. Download fxpt from Github and place it in your PYTHONPATH directory. Run following code in Script Editor or make a shelf button.

from fxpt.fx_search import fx_search
fx_search.run()

Comments are closed.