Use the following steps to expose custom Knowledge Fusion functions to the Expressions subsystem:
Define the function using Knowledge Fusion in a .dfa file and either:
Interactively add the folder containing the .dfa file to the search directories list in the Knowledge Fusion Preferences dialog box.
Or
Put the .dfa file in the dfa folder of NX automation folder structure and set the UGII_USER_DIR
, UGII_SITE_DIR
, and UGII_VENDOR_DIR
environment variables to point to the automation folder.
Note:
You can also add the complete path to this NX automation folder structure to a custom_dirs.dat file.
Include the DesignLogic=Yes
flag in the function definition. If this flag is not defined or is set to No
, the custom function will not be exposed to the expressions subsystem. Set this flag to Yes
to enable NX users to see and use this function in the Function Builder launched from within the Expressions dialog box.
Please note that users should be careful in exposing custom functions because the expressions subsystem supports only a subset of the data types supported by knowledge fusion.
Currently the Expression subsystem supports integers, numbers, strings, boolean, points and vectors data types. Hence functions that accept and return integers, numbers, strings, boolean, points and vectors can be exposed to expressions subsystem.
Currently the expressions subsystem does not support frames, instances, user or lists data types. Hence functions that accept or return frames, instances, user or lists cannot be exposed to expressions subsystem.
Functions that accept or return data type any may only be exposed to the expressions subsystem if the actual data contained in the any is one of the data types supported by the expressions subsystem.
Note:
The filename of the .dfa file that contains the custom functions appears as the name for the category in which the exposed functions appear in the function builder.
Following is an example of reusing functions in expressions:
#! NX/KF 5.0
DefClass: func_test (ug_base_part);
##############################################################################
Defun: custom_find_midPoint(
#+
DesignLogic=Yes
----------------------------------------------------------------------------
Description:
#.
Returns the mid point of 2 given points
.#
Input:
(Point) $p1 -
First Point
(Point) $p2 -
Second Point
----------------------------------------------------------------------------
#-
Point $p1, #.Specify First point#
Point $p2 #.Specify second point#
)
@{
$mid_point<<Point( (LocalX($p1)+LocalX($p2))/2, (LocalY($p1)+LocalY($p2))/2,(LocalZ($p1)+LocalZ($p2))/2 );
LocalZ($p1)+LocalZ($p2))/2 );
#+
---------------------------------------------------------------------------—
Returns:
(Any) - #.The mid point#
See Also:
---------------------------------------------------------------------------—
#-