hm_getincrementalname

Returns a unique incremental name from a specified base name and one or more entity types.

Syntax

hm_getincrementalname entity_type_list base_name ?start_num? ?num_digits? ?separator?

Type

HyperMesh Tcl Query Command

Description

This command returns a unique incremental name from a specified base name and one or more entity types (for example, name1, name2, etc.). Multiple entity types might require the same name (generate comp/mat/prop with same name), so the returned name is unique across the specified entity types.

Inputs

entity_type_list
A quoted list of entity types to consider for generating the name. A unique incremental name is found considering all of the specified types. Only named entity types are valid.
base_name
The base name to use for generating the incremental name. A blank string can be specified to just use the incremental ID as the name. Names with spaces must be enclosed in quotes.
start_num
An argument that specifies the starting number for generating the incremental name. Unless specified as 0, the increment counter always starts at 1. Valid values are:
Non-negative integer - Find the first available incremental name starting from this value.
-1 - Use the highest available incremental name (the generated name never falls inside of existing names). This is the default.
-2 - Use the lowest available incremental name (the generated name could fall inside of existing names).
num_digits
An argument that specifies the number of digits to use for generating the incremental number. If 0, use the minimum number of required digits (default). If the generated incremental number does not fit within the specified value, an error is returned.
separator
An argument that specifies the separator (delimeter) that will be appended between the base name and the number. Only valid when start_num is -1.

Examples

Assume a model has entities with the following names:

Components:
  • 1
  • 2
  • 4
  • 5
  • my_name1
  • my_name2
  • my_name4
  • my_name5
  • my_names001
  • my_names008
Materials:
  • my_names001
  • my_names002
Properties:
  • my_names001
  • my_names009

The generated names for the examples are shown below the command.

To generate a name based off of components in the form N, where N is the incremental ID of any length, using the highest available incremental name:

hm_getincrementalname "comps" ""

or

hm_getincrementalname "comps" "" -1
6

To generate a name based off of components in the form N, where N is the incremental ID of any length, using the lowest available incremental name:

hm_getincrementalname"comps" "" -2
 3

To generate a name based off of components in the form N, where N is the incremental ID of any length, using the lowest available incremental name starting from 0:

hm_getincrementalname "comps" "" 0
0

To generate a name based off of components in the form N, where N is the incremental ID of any length, using the lowest available incremental name starting from 1:

hm_getincrementalname "comps" "" 1
3

To generate a name based off of components in the form N, where N is the incremental ID of any length, using the lowest available incremental name starting from 4:

hm_getincrementalname "comps" "" 4
6

To generate a name based off of components in the form N, where N is the incremental ID of any length, using the lowest available incremental name starting from 50:

hm_getincrementalname "comps" "" 50
50

To generate a name based off of components in the form my_nameN, where N is the incremental ID of any length, using the highest available incremental name:

hm_getincrementalname "comps"
            my_name

or

hm_getincrementalname "comps" my_name -1
my_name6

To generate a name based off of components in the form my_namesNNN, where NNN is the fixed incremental ID length, using the highest available incremental name:

hm_getincrementalname "comps" my_names -1 3
my_names009

To generate a name based off of components, properties and materials, in the form my_namesNNN, where NNN is the fixed incremental ID length, using the highest available incremental name:

hm_getincrementalname "comps props mats" my_names -1 3
my_names010

To generate a name based off of components, properties and materials, in the form my_namesNNN, where NNN is the fixed incremental ID length, using the lowest available incremental name:

hm_getincrementalname "comps props mats" my_names -2 3
my_names003

To generate a name based off of components and materials, in the form my_nameNNN, where NNN is the fixed incremental ID length, using the highest available incremental name:

hm_getincrementalname "comps mats" my_names -1 3
my_names009

To generate a name based off of components and materials, in the form my_nameNNN, where NNN is the fixed incremental ID length, using the highest available incremental name:

hm_getincrementalname "comps mats" my_names -2 3
my_names003

Errors

Incorrect usage results in a Tcl error. To detect errors, you can use the catch command:
if { [ catch {command_name...} ] } {
   # Handle error
}

Version History

11.0.130

2020 - Added new option separator.