Production Applications: Customized Tool Database
Creo TOOLKIT supports integration of theCreo NC tool search command with external tool databases. These functions and callbacks allow users to create queries for third-party tool manager applications. These applications query external databases (you can specify more than one) and return logical tool data to Creo Parametric.
Overview
Creo TOOLKIT supplies functions that allow integration of the Tool Selection user interface with a third-party tool manager application. This integration consists of includes three areas of functionality:
•  The ability to preregister one or more databases with the Creo Parametric user interface, and to assign custom search parameters to each database. Custom search parameters are items which would not be included natively inside of Creo Parametric, but which could be used to initiate or narrow the tool search.
•  Callback functions, that are invoked when the user opts to search inside the tool database. Within the callback functions, the application can extract the native and non-negative search parameters and use these parameters to execute the search.
•  The ability to return a list of detailed results to Creo Parametric to be displayed in the results dialog box.
Setting up the Database and Custom Search Parameters
The functions described in this section enable you to setup the external database and custom search parameters supported by the database.
Functions Introduced:
The function ProMfgdbDataAlloc() allocates a ProMfgdbData handle containing database and search information.
The function ProMfgdbDataDbnameAdd() adds the name of an external tool database to the handle allocated by ProMfgdbDataAlloc(). To specify more than one database, make multiple calls to ProMfgdbDataDbnameAdd().
The function ProMfgdbNameCreate() allocates memory for a handle containing the name of a group into which search options are organized.
The function ProMfgdbSearchoptCreate() allocates and initializes a structure for a custom search option. It requires that the option be assigned to a group, typically this would be allocated from ProMfgdbNameCreate().
The function ProMfgdbDataSearchoptAdd()adds a custom search option to the ProMfgdbData handle.
The function ProMfgdbSearchoptApplicDataAdd() specifies the category and object type for which a custom search option is valid. Call this function at least once for each option. Assign an option to multiple categories or object types with multiple calls to this function.
The function ProMfgdbSearchoptAllowedValueAdd() adds valid values available for a search option. Assign multiple values with multiple calls to this function.
Registering the External Database
The function described in this section allows you to register the Creo TOOLKIT application to search the external tool database.
Function Introduced:
The function ProMfgdbRegister() registers an external database with Creo Parametric. You should supply the ProMfgdbData handle you created for your external database(s).
The function also requires that you supply three callbacks:
•  A ProMfgdbLoginAction, which is called by Creo Parametric when the user attempts to initiate access to the external database.
•  A ProMfgdbLogoffAction, which is called when the user is ready to close the connection to the external database.
•  A ProMfgdbSearchAction, which provides the custom implementation for the search, and provides the results back to Creo Parametric.
Finally, the function requires that you supply the object category. Although there are several categories listed for this function, currently the function supports only the following category:
•  PROMFGDBCAT_CUTTING_TOOL
  When one or more external databases have been registered with Creo Parametric, a search icon is displayed in the Tool Setup dialog box in Creo Parametric as shown in the following figure. Click the search icon to invoke the Cutting Tool Search dialog box.
Image
Querying the External Database
When users invoke the Search icon to construct a query, they will be presented with the Cutting Tool Search dialog, as shown in the following figure. Within the dialog, users can specify the query parameters, values and group the query constraints with logical operators. When the user completes the query and executes the Find command, Creo Parametric will call the Creo TOOLKIT application with the data from this dialog.
Image
The functions described in this section enable you to convert the Creo Parametric queries into a format that can be used with the external database.
Creo Parametric tool database queries are arranged in a tree format, as shown in the following figure. Leaf nodes contain expressions, for example, units and type.
Image
Functions Introduced:
ProMfgdbQuerynodeIsLeaf()
The functions ProMfgdbQuerynodeLeftChildGet() and ProMfgdbQuerynodeRightChildGet() return either the left or right branch of a query node, respectively.
ProMfgdbQuerynodeLogicOperGet()ProMfgdbQuerynodeIsLeaf()
ProMfgdbQuerynodeExprGet()
ProMfgdbQueryTargetGet()
After the query functions return expressions from a leaf node, your Creo TOOLKIT application can gather information contained in the expressions. The following functions return attributes and operators contained in the returned expressions of a leaf node.
The function ProMfgdbExprNameGet() returns the name of the attribute contained in the specified expression. The function ProMfgdbExprCategoryGet() returns the category of the attribute contained in the specified expression. The functions ProMfgdbExprValueGet() and ProMfgdbExprValueTypeGet() return the value and value type contained in the specified expression, respectively. The function ProMfgdbExprCompopGet() returns the comparison operator (=, <, >, and so on) contained in the specified expression.
Returning the Search Results
The functions in this section enable you to populate the results of the query to the external database and pass them back to Creo Parametric so that Creo Parametric will display them appropriately in the results window.
Functions Introduced:
Use the function ProMfgdbMatchAlloc() to allocate memory for the structure used to store a match to the query.
The function ProMfgdbMatchParamAdd() adds a parameter to the match structure. Make multiple calls to this function to add multiple parameters to the match.
An example of the results passed back from a database query is shown in the following figure:
Image