part naming scripts (obsolete)

The Naming Tab is being transitioned to the Scripting Tab

Part name and description generating scripts

Scripts can be written to automatically generate part names and descriptions using part configuration inputs.

The name and description generating scripts are entered on the Naming tab in Template editor.

Writing Scripts
Each line of a script produces a segment of text to be included in the name or description. Lines may result in empty text. Blanks lines are allowed. Comment lines may also be included by starting a line with a slash ('/').

Each line of actual script must take the form "command(params)", where "command" is one of the defined commands listed in the reference below. The number of parameters differs for each command, and they can also be commands themselves in the same general form. Commands may be quite long and complex with many levels of nested commands as parameters. Thus, it can be quite difficult to ensure that all openning parentheses have corresponding closing parenthesis in the right places. To help with this problem, a visual aid for matching opening and closing parentheses is shown in the script text boxes. When the cursor is positioned directly after an opening parenthesis, the corresponding closing parenthesis will be highlighted. And similarly, when the cursor is positioned directly after a closing parenthesis, the corresponding opening parenthesis will be highlighted.

Command Reference

Commands that return text:

text("---")
Simply outputs the text between the quotes.

format((number_command), (pattern))
Formats a number produced by the result of the number command (see Commands that return numbers) using the specified pattern. Patterns may be quite complex. The patterns are simply provided to the Java DecimalFormat. A full specification for the patterns may be found at http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html .

For most intents and purposes it will be sufficient to use patterns like ##0.00##
The # indicates that a digit should be included if it is non-zero.
The 0 indicates that a digit should be included even if it is zero.
The . indicates the decimal point location.

lowercase(text_command)
Returns text that is all lower case.

uppercase(text_command)
Returns text that is all upper case.

substring((text_command), (start_index_number_command), (end_index_number_command))
Returns the portion of text specified by the text command parameter that is between the character indices specified by the start index comand and the end index command. The end index command may optionally be left out, in which case the end index is simply the end of the text.

config-text(config_symbol)
Returns the value of the configuration input with the given symbol in text format.

Commands that return numbers:

num(number or command)
A simple constant number may be specified or a command that evaluates to a number or even a command that evaluates to text that may be converted to a number.

config-num(config_symbol)
Returns the value of the configuration input with the given symbol as a number.

Also see the section on Comparison commands which are special number commands that return either 0 or 1. They may also be used anywhere where number commands are expected.

Conditional command

if((test_number_command), (accept_command), (reject_command))
The test command must evaluate to a number. If it evaluates to anything but 0, the result of the accept command will be returned, otherwise the result of the reject command will be returned. The reject command is optional.

The accept and reject commands may evaluate to either numbers or text. As such, a conditional command may be embedded in another command as a parameter.

Comparison commands

equals((command1), (command2))
Returns 1 if the two commands evaluate to the same thing. Returns 0 otherwise.

notEquals((command1), (command2))
Returns 1 if the two commands do NOT evaluate to the same thing. Returns 0 otherwise.

greater((command1), (command2))
Returns 1 if command1 evaluates to something greater than what command2 evaluates to. Returns 0 otherwise. Text commands are compared using alphabetical order.

greaterEquals((command1), (command2))
Returns 1 if command1 evaluates to something greater than or equal to what command2 evaluates to. Returns 0 otherwise. Text commands are compared using alphabetical order.

less((command1), (command2))
Returns 1 if command1 evaluates to something less than what command2 evaluates to. Returns 0 otherwise. Text commands are compared using alphabetical order.

lessEquals((command1), (command2))
Returns 1 if command1 evaluates to something less than or equal to what command2 evaluates to. Returns 0 otherwise. Text commands are compared using alphabetical order.

and((number_command1), (number_command2))
Returns 1 if both command1 and command2 evaluate to something other than 0.

or((number_command1), (number_command2))
Returns 1 if either command1 or command2 evaluates to something other than 0. 
Comments