Utility Functions

This topic lists utility functions that help you extend the Adams View macro language. The functions help you access information that is not easy to access using the standard Adams View macro language. You can use the utility functions in macros and in dialog boxes.
The following functions are used by the template-based products. To see information on all functions available in the Function Builder, see the Function Builder online help.

Units-Conversion Functions

The units-conversion functions convert an input value to a different unit system. The units-conversion functions are:

convert_from_units

Definition
convert_from_units converts the input value from a unit type to the equivalent modeling units. It accepts any valid units string (for example, mm, newton, or inch) for the unit type. It returns the converted value.
Format
REAL convert_from_units (STRING from_units, REAL in_value)
Arguments
 
from_units
A string specifying the current units of the argument in_value.
in_value
A real number to be converted.
Examples
The following example converts the current length units, which are in inches (inch), to millimeters (mm):
variable set variable=units_convert &    
   real_value=(eval(CONVERT_FROM_UNITS("inch", 1.0)))
units_convert = 25.4

convert_units

Definition
convert_units returns the conversion factor necessary to convert a value from the current units (from_units) to the desired units (to_units). It accepts any valid units string (for example, mm, newton, or inch) for the units strings. The units should be equivalent modeling units of length, force, mass, time, or angle.
Format
REAL convert_units (STRING from_units, REAL to_units)
Arguments
 
from_units
A string specifying the current units.
to_units
A string specifying the desired units.
Examples
The following example returns the conversion factor necessary to convert miles to millimeters:
variable set variable=convert_factor &    
   real_value=(CONVERT_UNITS( "mile" , "mm" ))
convert_factor = 1.609344E+06

convert_to_radians

Definition
convert_to_radians converts an angle from degrees to radians. You specify the input value in current modeling angular units.Format
REAL convert_to_radians (REAL in_value)
Arguments
 
in_value
A real number to be converted.
Examples
The following example converts the current modeling angular units, which are in degrees, to radians:
variable set variable=angle_radians &
   real_value=(CONVERT_TO_RADIANS(90))
angle_radians = 1.5707963268

units_to_mks

Definition
units_to_mks returns the conversion factor from user units to database units (meters, kilograms, seconds, radians, or mks).Format
REAL units_to_mks (INTEGER units)
Arguments
 
units
An integer value.
Examples
The following example returns the conversion factor necessary to change degrees to database units:
variable ser variable=myvar1 &  
  real_value=90.0 units=angle
variable set variable=myvar2 &
  real_value=(UNITS_TO_MKS( myvar1.units ))
myvar2 = 1.7453...E-02

String Functions

The string functions allow you to manipulate character strings. The string functions are:

str_assembly_class

Definition
str_assembly_class returns the assembly class of an assembled model. Your template-based product stores the returned information in the assembly_class variable under all assemblies. For Adams Car, typical assembly classes include suspension and full_vehicle. You can also extend the assembly classes.
If no assembly variable exists within the assembled model, str_assembly_class returns an empty string.
Format
STRING str_assembly_class (OBJECT assembled_model)
Arguments
 
assembled_model
Name of the assembled model.
Examples
variable set variable=current_class &
   string_value=(STR_ASSEMBLY_CLASS(.susp_assy))
current_class = "suspension"

str_char_swap

Definition
str_char_swap changes a single character in a string (object_name) at a particular location (index) to another character string. It changes the characters as specified in swap_str.
str_char_swap compares the strings and changes them only in the string following the last . in object_name. In addition, swap_str must be two or more characters long and contain an even number of characters.
The first half of swap_str determines the characters to be changed ("from characters") and the second half of swap_str determines the characters to which the characters are to be changed ("to characters"). If str_char_swap does not change any characters, it returns the original object_name string.
Format
STRING str_char_swap (STRING object_name, STRING swap_str, INT index)
Arguments
 
object_name
A string that usually contains an object's name.
swap_str
A string that describes the rules for character changing.
index
An integer that specifies the index of the character to be changed.
Examples
In the following Adams Car example, lrrl is the string that defines what should be changed. The first half of the string (lr) represents the valid "from characters." The second half of the string (rl) represents the "to characters."
If the example finds one of the "from characters" at position 3 in the string ._front_susp.ground.hpl_lca_front, it replaces the "from characters" with the corresponding "to characters." In this example, l would change to r.
variable set variable=symmetric_name &
   string_value=(STR_CHAR_SWAP("._front_susp.ground.hpl_lca_front",
"lrrl", 3))
symmetric_name = "._front_susp.ground.hpr_lca_front"

str_filename

Definition
str_filename strips an input string (in_str) to a base file name (with extension) and then substitutes a new string (new_str) for the old string (old_str) if the old string exists in the base name. If old_str occurs more than once in the input string, str_filename only replaces the last occurrence.
Format
STRING str_filename (STRING in_str, STRING old_str, INT new_str)
Arguments
 
in_str
The input string, which is usually a file path.
old_str
The string to be replaced.
new_str
The string to replace old_str.
Examples
variable set variable=base_filename &
   string_value=(STR_FILENAME("/usr/car.cdb/test.tpl", "tpl","sub"))
base_filename = "test.sub"

str_model_class

Definition
str_model_class returns a model's model class. This information is stored in the model_class variable under all models. If no such variable exists within the model, str_model_class returns an empty string. Typical model classes include template, subsystem, and assembly.
Format
STRING str_model_class (OBJECT model)
Arguments
 
model
A model entity.
Examples
variable set variable=current_class &
   string_value=(STR_MODEL_CLASS(._front_susp))
current_class = "template"

str_prefix

Definition
str_prefix returns the generic prefix for a given string (object_name). The length of the return string is always four characters long. str_prefix also pares the input down to only the string following the last . in object_name.
Format
STRING str_prefix (STRING object_name)
Arguments
 
object_name
A string that usually contains an object's name.
Examples
variable set variable=name_prefix &
   string_value=(STR_PREFIX("._front_susp.ground.hpl_lca_outer"))
name_prefix = "hps_"

str_remove

Definition
str_remove trims an input string (in_str) by removing a string (begin_str) from the beginning of in_str and truncating in_str starting from the last occurrence of end_str.
str_remove removes begin_str before removing end_str so if the beginning and ending string in in_str overlap, str_remove only removes begin_str.
Format
STRING str_remove (STRING in_str, STRING begin_str, STRING end_str)
Arguments
 
in_str
The input string.
begin_str
A string to be removed from the beginning of in_str.
end_str
A string that defines where to truncate the input string.
Examples
variable set variable=trim_string &
    string_value=(STR_REMOVE("abcdef", "ab", "ef"))
trim_string = "cd"
variable set variable=trim_string &
   string_value=(STR_REMOVE("abcdef", "", "ef"))
trim_string="abcd"

str_replace

Definition
str_replace replaces a string (old_str) with a new string (new_str) in the string in_str. If there are multiple occurrences of old_str, str_replace replaces the last occurrence.
Format
STRING str_replace (STRING in_str, STRING old_str, STRING new_str)
Arguments
 
in_str
The input string.
old_str
The string to be replaced.
new_str
The string to replace old_str.
Examples
variable set variable=other_filename &
   string_value=(STR_REPLACE("/usr/car.cdb/test.tpl", "test",
"junk"))
other_filename = "/usr/car.cdb/junk.tpl"

str_typecheck

Definition
str_typecheck returns a 1 if a list of characters (type) matches the third character in the base name of an object's name (object_name). str_typecheck always pares down the input to only the string following the last . in object_name.
You can specify more than one character in type.
Format
STRING str_typecheck (STRING object_name, STRING type)
Arguments
 
object_name
A string that usually contains an object's name.
type
A list of characters to match. Allowed characters are l, r, and s.
Examples
variable set variable=check_type &
   string_value=(STR_TYPECHECK("._front_susp.ground.hpl_lca_outer",
"ls"))
check_type = 1
variable set variable=check_type &
   string_value=(STR_TYPECHECK("._front_susp.ground.hpl_lca_outer",
"r"))
check_type = 0
 

Database Functions

The database functions let you manage and access the databases of your template-based product. The database functions are:

cdb_alias2path

Definition
cdb_alias2path returns the full path associated with a given table path alias or cdb_name. If cdb_alias2path does not find the full table path corresponding to the alias, it returns the input string. By returning the input string, you can input normal path names and filenames, and cdb_alias2path returns them without modification.
Format
STRING cdb_alias2path (STRING path_alias)
Arguments
 
path_alias
Alias used for internal reference to database.
Examples
This example finds the file system path associated with database prototype:
variable set variable=a2p &
   string_value=(eval(cdb_alias2path("prototype")))
a2p = "/local/proto.cdb"
 

cdb_get_os

Definition
cdb_get_os returns the operating system that Adams is running on. Two options exist. For Windows-based system the string returned is "nt" and for Linux-based systems the string is "unix".
Format
STRING cdb_get_os ()
Arguments
No arguments are to be given
Examples
This example finds the operating system type that Adams is running on:
variable set variable=go &
string_value=(eval(cdb_get_os()))
i2e = "unix"

cdb_inherit_permissons

Definition
cdb_inherit_permissions tries on Linux to set the read and write permissions of a or directory to the same read and write permissions as the parent folder has. Any execution permissions are removed. It returns 0 on success and an error message on failure. On Windows the function does nothing and always returns 0.
Format
STRING cdb_inherit_permissions (STRING input_name)
Arguments
 
input_name
File system path to file or folder which is to inherit its file permissions
Examples
This example sets the permissions for the file <proto>/bushings.tbl/my_bush.bus:
variable set variable=ihp &    integer_value=(eval(cdb_inherit_permissions("<proto>/bushings.tbl/my_bush.bus")))
ihp = 0

cdb_input2base

Definition
cdb_input2base returns the base name of a file (input_name). It strips the input_name of both its file system path prefixes and extension or suffix, if any.
Format
STRING cdb_input2base (STRING input_name)
Arguments
 
input_name
File system path to be converted to base name.
Examples
This example finds the base name for the file /local/proto.cdb/bushings.tbl/my_bush.bus:
variable set variable=i2b &    string_value(eval(cdb_input2base("/local/proto.cdb/bushings.tbl/m
y_bush.bus")))
i2b = "my_bush"

cdb_input2db

Definition
cdb_input2db returns the database name associated with the path supplied (input_name).
If cdb_input2db does not find the corresponding alias, it returns an empty string. Can with an advantage be used in combination with cdb_path2alias to find the database name in a of database paths as well as in absolute file system paths.
Format
STRING cdb_input2db (STRING input_name)
Arguments
 
input_name
Database path to extract database name from
Examples
This example finds the database name for database folder <proto.cdb>/assemblies.tbl:
variable set variable=i2db &
   string_value=(eval(cdb_input2db("mdids://proto/assemblies.tbl")))
i2db = "proto"
This example finds the database name for the file /local/proto_db.cdb/assemblies.tbl/my_assy.asy:
variable set variable=i2db &
   string_value=(eval(cdb_input2db(cdb_path2alias("/local/proto_db.cdb/assemblies.tbl/my_assy.asy"))))
i2db = "proto"
given that the database is registered in the sessions as
DATABASE proto /local/proto_db.cdb

cdb_input2ext

Definition
cdb_input2ext returns the extension or suffix of a file (input_name). It returns an empty string if it finds no extension
Format
STRING cdb_input2ext (STRING input_name)
Arguments
 
input_name
File system path to be converted to extension.
Examples
This example finds the extension for the file /local/proto.cdb/bushings.tbl/my_bush.bus:
variable set variable=i2e &
   string_value=(eval(cdb_input2ext("/local/proto.cdb/bushings.tbl/my
_bush.bus")))
i2e = "bus"

cdb_input2file

Definition
cdb_input2file returns the filename contained in input_name. cdb_input2file strips input_name of any file system path prefix and returns the result.
Format
STRING cdb_input2file (STRING input_name)
Arguments
 
input_name
File system path to be converted to filename.
Examples
This example finds the filename for the file /local/proto.cdb/bushings.tbl/my_bush.bus:
variable set variable=i2file &
   string_value=(eval(cdb_input2file("/local/proto.cdb/bushings.tbl/my_bush
.bus")))
i2file = "my_bush.bus"

cdb_input2full

Definition
cdb_input2full returns the file system path of a filename containing a database alias. If cdb_input2full finds no database alias present, it returns the input string.
Format
STRING cdb_input2full (STRING input_name)
Arguments
 
input_name
Filename with database alias to be converted to file system path.
Examples
This example finds the file system path for the file mdids://prototype/bushings.tbl/my_bush.bus:
variable set variable=i2full &
  string_value=(eval(cdb_input2full("mdids://prototype/bushings.tbl/
my_bush.bus")))
i2full = "/local/proto.cdb/bushings.tbl/my_bush.bus"

cdb_input2path

Definition
cdb_input2path returns the file system path prefix of a filename. If the path prefix is not present, cdb_input2path returns an empty string.
Format
STRING cdb_input2path (STRING input_name)
Arguments
 
input_name
Filename to be converted into file system path prefix.
Examples
This example finds the file system path prefix for the file /local/proto.cdb/bushings.tbl/my_bush.bus:
variable set variable=i2p &
   string_value=(eval(cdb_input2path("/local/proto.cdb/bushings.tbl/my_bush.bus")))
i2p = "/local/proto.cdb/bushings.tbl"

cdb_input2tblpth

Definition
cdb_input2tblpth returns the aliased path associated with a given table path pointing to a file. If cdb_input2tblpth does not find a path alias corresponding to the full path name, it returns the input string. By returning the input string, cdb_input2tblpth allows you to enter normal path names and filenames and returns them without modification. cdb_input2tblpth is stricter than the similar cdb_path2alias in the sense that if the table in the path does not exist as a registered table the database will not be substituted with the alias. The function works only with files (or folders) under tables or tables ending with a forward slash.
Format
STRING cdb_input2tblpth (STRING input_name)
Arguments
 
input_name
Filename to be converted into an aliased database path
Examples
This example finds the file system path prefix for the file /local/proto.cdb/bushings.tbl/my_bush.bus:
variable set variable=i2tp &
   string_value=(eval(cdb_input2tblpth("/local/proto.cdb/bushings.tbl/my_bush.bus")))
i2tp = "<proto>/bushings.tbl/mybush.bus"
given that the database is registered in the sessions as
DATABASE prototype /local/proto.cdb
This example finds the file system path prefix for the file /local/proto.cdb/no_registered.tbl/my.bus:
variable set variable=i2tp &
   string_value=(eval(cdb_input2tblpth("/local/proto.cdb/no_registered.tbl/my.bus")))
i2tp = "/local/proto.cdb/no_registered.tbl/my.bus"
if the database is not registered, or if it is registered but the if the table no_registered.tbl is not a registered table in the session.

cdb_nt2unix_path

Definition
cdb_nt2unix_path changes the file separator from backslash (\) to forward slash (/) in the provided string.
Format
STRING cdb_nt2unix_path(STRING input_name)
Arguments
 
input_name
Filename to be converted into file unix style path.
Examples
This example finds the file system path prefix for the file c:\local\proto.cdb\bushings.tbl\my_bush.bus:
variable set variable=n2up &
   string_value=(eval(cdb_nt2unix_path("c:\\local\\proto.cdb\\bushings.tbl\\my_bush.bus")))
n2up = "c:/local/proto.cdb/bushings.tbl/my_bush.bus"
 
Note:  
To define a string with backslash in Adams, the backslash must be escaped with an additional backslash. Hence each backslash is represented by double backslashes in the above example.

cdb_path2alias

Definition
cdb_path2alias returns the path alias associated with a given table path alias or cdb_name. If cdb_path2alias does not find a path alias corresponding to the full path name, it returns the input string. By returning the input string, cdb_path2alias allows you to enter normal path names and filenames, and returns them without modification.
 
Note:  
When comparing strings from filenames, remember that Linux filenames are case sensitive. Windows filenames are not.
Format
STRING cdb_path2alias (STRING path)
Arguments
 
path
File system path of the database.
Examples
This example finds the database alias associated with database:
variable set variable=p2a &
   string_value=eval(cdb_path2alias("/local/proto.cdb/assemblies.tbl")))
p2a = "mdids://prototype/assemblies.tbl"
given that the database is registered in the sessions as
DATABASE prototype /local/proto.cdb

cdb_runtime_path_port

Definition
cdb_runtime_path_port returns the filename of the input string (input_name) converted to the Linux format (using forward slashes, that is, "/"). You will find cdb_runtime_path_port useful when you are sharing filenames between Linux and Windows file systems. It also lets you use a database alias instead of a full file system path.
Format
STRING cdb_runtime_path_port (STRING input_name)
Arguments
 
input_name
File system path to be converted to a Linux specific filename format.
Examples
This example returns the Linux version of the filename for the file mdids://prototype\bushings.tbl\my_bush.bus:
variable set variable=rpp &
   string_value=(eval(cdb_runtime_path_port("mdids://prototype\\bushings.tbl\\my_bush.bus")))
rpp = "mdids://prototype/bushings.tb/my_bush.bus"

cdb_search_file

Definition
cdb_search_file returns the file system path of the input file (filename). First, it checks to determine if the filename as input corresponds to an existing file. It expands any database alias to its corresponding file system path and looks for the filename at the resultant location. If it finds no file, it removes any file system path prefix from the filename and begins to search the different databases in the specified search order.
 
Notes:  
The search order is important. If two identically named files exist in different databases, the search order determines which of these files cdb_search_file finds and returns.
cdb_search_file returns an empty string if it does not find the requested filename after searching the databases.
Format
STRING cdb_search_file (STRING class_name, STRING filename, INT level)
Arguments
 
class_name
The type class name for the table in which to search for the file. It is defined in the configuration files.
filename
The filename, either with or without any path prefix, to be found.
level
The level in the search list at which to start searching. The value is usually 1, which indicates a full search.
Examples
This example finds the file system path for file my_bush.bus:
variable set variable=sfile &
string_value=(eval(cdb_search_file("bushing","my_bush.bus",1)))
sfile="/local/proto.cdb/bushings.tbl/my_bush.bus"

cdb_standardize_alias

Definition
cdb_standardize_alias returns the canonical form of the database, that is, "<prototype>" as opposed to the protocole form "mdids://prototype" of the input string (input_name). It also removed any "file://" references from the path.
Format
STRING cdb_standardize_alias(STRING input_name)
Arguments
 
input_name
File system path to be converted to a Linux specific filename format.
Examples
This example returns the canonical database formatted path of the filename for the file mdids://prototype\bushings.tbl\my_bush.bus:
variable set variable=cdb_sa &
   string_value=(eval(cdb_standardize_alias("mdids://prototype/bushings.tbl/my_bush.bus")))
cdb_sa = "<prototype>/bushings.tb/my_bush.bus"
This example returns the protocol style file path of the filename for the file
file://c:\\temp/my_file.txt:
variable set variable=cdb_sa &
   string_value=(eval(cdb_standardize_alias("file://c:\\temp/my_file.txt")))
cdb_sa = "c:\temp/my_file.txt"

File Functions

The file functions return information about the roles and variants of templates, subsystems and assemblies:

template_hdr_major_role

Definition
template_hdr_major_role returns the major role of a template. Your template-based product stores the major role information in the header information of all template files (.tpl). template_hdr_major_role automatically opens a template file, retrieves the information from the file header, and closes the file.
Format
STRING template_hdr_major_role (STRING filename)
Arguments
 
filename
String that contains the full path of the template file.
Examples
This is an example of the header information that is stored in an Adams Car template file:
$------------------------TEMPLATE_HEADER----------------------$
[TEMPLATE_HEADER]
MAJOR_ROLE = 'suspension'
TIMESTAMP ='1999/02/04,13:13:38'
HEADER_SIZE = 5
The following example returns the major role of a template, which it obtains from the header information shown above:
variable set variable=tpl_major_role &
   string_value=(TEMPLATE_HDR_MAJOR_ROLE
("mdids://shared/template.tbl/_dbl_wish.tpl"))
tpl_major_role = "suspension"

subsystem_hdr_major_role

Definition
subsystem_hdr_major_role returns the major role of a subsystem. Your template-based product stores the major role information in the header information of all subsystem files (.sub). subsystem_hdr_major_role automatically opens a subsystem file, retrieves the information from the file header, and closes the file.
Format
STRING subsystem_hdr_major_role (STRING filename)
Arguments
 
filename
String that contains the full path of the subsystem file.
Examples
This is an example of the header information that is stored in an Adams Car subsystem file:
$--------------------------SUBSYSTEM_HEADER -----------------------$
[SUBSYSTEM_HEADER]
TEMPLATE_NAME = ’mdids://shared/templates.tbl/_double_wishbone.tpl’
MAJOR_ROLE = ’suspension’
MINOR_ROLE = ’front’
TIMESTAMP = ’1999/02/04,17:18:18’
The following example returns the major role of an Adams Car subsystem, which it obtains from the header information shown above:
variable set variable=sub_major_role &
   string_value=(SUBSYSTEM_HDR_MAJOR_ROLE("mdids://shared/subsystem.tbl/
front_susp.sub"))
sub_major_role = "suspension"

subsystem_hdr_minor_role

Definition
subsystem_hdr_minor_role returns the minor role of a subsystem. Your template-based product stores the minor role information in the header information of all subsystem files (.sub). subsystem_hdr_minor_role automatically opens a subsystem file, retrieves the information from the file header, and closes the file.
Format
STRING subsystem_hdr_minor_role (STRING filename)
Arguments
 
filename
String that contains the full path of the subsystem file.
Examples
This is an example of the header information that is stored in an Adams Car subsystem file:
$------------------------SUBSYSTEM_HEADER ----------------------$
[SUBSYSTEM_HEADER]
TEMPLATE_NAME = ’mdids://shared/templates.tbl/_double_wishbone.tpl’
MAJOR_ROLE= ’suspension’
MINOR_ROLE= ’front’
TIMESTAMP= ’1999/02/04,17:18:18’
The following example returns the minor role of an Adams Car subsystem, which it obtains from the header information shown above:
variable set variable=sub_minor_role &
   string_value=(SUBSYSTEM_HDR_MINOR_ROLE("mdids://shared/subsystems
.tbl/front_susp.sub"))
sub_minor_role = "front"
 

read_subsystem_variants

Definition
read_subsystem_variants returns a list of variants defined in a subsystem file. Your template-based product scans the variant information in the specified subsystem file (.sub or .xml). read_subsystem_variants automatically opens a subsystem file, retrieves the information from the file, and closes the file. If no variant definitions are found in the subsystem, an empty string is returned.
Format
STRING read_subsystem_variants (STRING filename)
Arguments
 
filename
String that contains the full path of the subsystem file.
Examples
The following example returns the variants of an Adams Car subsystem, which it obtains from the file as shown below:
variable set variable=sub_variants &
string_value=( READ_SUBSYSTEM_VARIANTS("<private>/subsystems.tbl/front_susp.sub"))
sub_variants = "default,baseline,sport,luxury"

read_assy_variants

Definition
read_assy_variants returns a list of variants defined in an assembly file. Your template-based product scans the variant information in the specified assembly file (.asy, .xml, or .bin). read_assy_variants automatically opens an assembly file, retrieves the information from the file, and closes the file. If no variant definitions are found in the assembly, an empty string is returned.
Format
STRING read_assy_variants (STRING filename)
Arguments
 
filename
String that contains the full path of the assembly file.
Examples
The following example returns the variants of an Adams Car assembly, which it obtains from the file as shown below:
variable set variable=assy_variants &
string_value=( READ_ASSY_VARIANTS("<private>/assemblies.tbl/full_vehicle.asy"))
assy_variants = "default,curb,GVW"

Database Lookup Functions

The database lookup functions find specified models or subsystems based on their classes or roles during a session.

model_class_exists

Definition
model_class_exists lets you easily determine if a model of a particular model class exists in the current session. model_class returns a 1 if a model of the specified model class exists.
Your template-based product stores the model class information in the model_class variable under all models. Typical model classes include template, subsystem, and assembly.
Format
INT model_class_exists (STRING model_class)
Arguments
 
model_class
String containing the model class.
Examples
if condition=(model_class_exists("assembly") == 0)
   ! No Assemblies !
end

subsystem_lookup

Definition
subsystem_lookup returns the subsystem contained in the assembled model with the specified major and minor role. If no such subsystem exists, subsystem_lookup returns no object or NONE.
Format
OBJECT subsystem_lookup (OBJECT model, STRING major_role, STRING minor_role)
Arguments
 
model
Name of the assembled model.
major_role
String containing the major role to look up.
minor_role
String containing the minor role to look up.
Examples
variable set variable=front_susp_subsystem &
   object_value=(eval(SUBSYSTEM_LOOKUP(.susp_assy, "suspension",
"front")))
front_susp_subsystem = .susp_assy.TR_Front_Suspension

subsystem_role_exists

Definition
subsystem_role_exists lets you easily determine if a subsystem of a particular role exists in an assembled model. subsystem_role_exists returns a 1 if the assembled model contains such a subsystem. Your template-based product stores the role information in the role variable that exists in each subsystem.
Format
INT subsystem_role_exists (OBJECT model, STRING role)
Arguments
 
model
Name of the assembled model.
role
String containing the role to look up.
Examples
if condition=(subsystem_role_exists(.fveh_assembly, "brake_system")
== 0)
   ! No Brakes !
end

subsystem_role_exists_in_variant

Definition
subsystem_role_exists_in_variant lets you easily determine if a subsystem of a particular role exists in an assembly variant. subsystem_role_exists_in_variant returns a 1 if the assembly variant contains such a subsystem.
Format
INT subsystem_role_exists_in_variant (OBJECT model, STRING role, STRING variant)
Arguments
 
model
Name of the assembled model.
role
String containing the role to look up.
variant
Name of the assembly variant to search.
Examples
if condition=(subsystem_role_exists_in_variant(.fveh_assembly, "brake_system", "default") == 0)
! No Brakes !
end

subsystem_lookup_in_variant

Definition
subsystem_lookup_in_variant returns the name of the subsystem contained in the assembly variant with the specified major and minor role. If no such subsystem exists, subsystem_lookup_in_variant returns an empty string. Use this function when the subsystem may not be currently loaded in session. For example, imagine an assembly with ten assembly variants, each referencing a different front suspension subsystem, only one of which is currently open. You can use subsystem_lookup_in_variant to find the front suspension referenced by one particular assembly variant, whether or not that subsystem is currently open.
Format
STRING subsystem_lookup_in_variant (OBJECT model, STRING variant, STRING major_role, STRING minor_role, INT index)
Arguments
 
model
Name of the assembled model.
variant
Name of the assembly variant to search.
major_role
String containing the major role to look up.
minor_role
String containing the minor role to look up.
index
Subsystem index to look up. If your assembly does not use subsystem indices, use index = 0.
Examples
variable set variable=front_susp_subsystem &
string_value=(eval(SUBSYSTEM_LOOKUP_IN_VARIANT(.susp_assy, "default", "suspension", "front", 0)))
front_susp_subsystem = "TR_Front_Suspension"

subsystem_lookup_index

Definition
subsystem_lookup_index returns the subsystem contained in the assembled model with the specified major and minor role and index. If no such subsystem exists, subsystem_lookup_index returns no object or NONE. Unlike subsystem_lookup_in_variant, this function will only find subsystems that are currently open in session.
Format
OBJECT subsystem_lookup_index (OBJECT model, STRING variant, STRING major_role, STRING minor_role, INT index)
Arguments
 
model
Name of the assembled model.
variant
Name of the assembly variant to search.
major_role
String containing the major role to look up.
minor_role
String containing the minor role to look up.
index
Subsystem index to look up. If your assembly does not use subsystem indices, use index = 0.
Examples
variable set variable=front_susp_subsystem2 &
object_value=(eval(SUBSYSTEM_LOOKUP_INDEX(.road_train, "default", "suspension", "front", 2)))
front_susp_subsystem2 = .road_train.f_susp_2

subsystems_count

Definition
subsystems_count returns the number of subsystems contained in the assembled model with the specified major and minor role. If no such subsystem exists, subsystems_count returns 0. Unlike subsystem_lookup_in_variant, this function will only count subsystems that are currently open in session.
Format
INT subsystems_count (OBJECT model, STRING major_role, STRING minor_role)
Arguments
 
model
Name of the assembled model.
major_role
String containing the major role to look up.
minor_role
String containing the minor role to look up.
Examples
variable set variable=rear_suspensions &
integer_value=(eval(SUBSYSTEMS_COUNT(.road_train, "suspension", "rear")))
rear_suspensions = 3

Miscellaneous Functions

This topic lists utility functions that help you extend the Adams View macro language. The functions help you access information that is not easy to access using the standard Adams View macro language. You can use the utility functions in macros and in dialog boxes.

ac_info_mass

Definition
ac_info_mass computes the aggregate mass of the assembly. This function ignores inactive parts.
Format
REAL ac_info_mass(OBJECT model)
Arguments
 
model
Name of the assembled model.
Examples
variable set variable_name=total_mass &
   real_value=(EVAL(ac_info_mass(.model_name)))

Organizing Custom Code

You can set up private and site repositories for storing:
Binaries that contain interface changes and macros
Libraries that contain linked subroutines and compiled functions
For example, when a group of users needs to access the same information or are working on the same project, you can create a custom site repository. By having a site repository, they can share site-specific versions of the template-based product and configuration files.
Also, a private repository is a convenient way for a single user to create several custom versions of a template-based product or to work on different projects. Private locations let you create an unlimited number of site binaries and libraries.
In the site or private repository, your template-based product creates a directory structure that mimics the installation directory structure. The directory contains subdirectories for each platform for which you created a binary or a library.
You control the location of the private repository using the privateDir setting. The privateDir setting tells Adams where to locate the appropriate files and where to store the resulting files. The default location of the private repository is as follows:

Default Location of Private Repository

 
Product name:
File name:
Adams Car
$HOME/acar_private
Where $HOME represents your user home directory when you log on to your computer.
 
 
Note:  
The following procedures show how you can define the site and private repositories for Adams Car. Follow the same basic procedures to define the site repository for your template-based product.

Defining Site Repositories

To define the site repository in Linux:

In Adams Toolbar, change the siteDir setting in the Adams Car preferences. For example, change it to:
/usr/people/someone/acar_site
You can also change the siteDir setting using the Registry Shell Tool from the command line. For example, at the command line enter:
adams2024_1 -c rtool
set /MDI/ACar/Preferences/siteDir /usr/people/someone/acar_site

To define the site repository in Windows:

1. From the Start menu, point to Programs, point to Adams 2024.1, and then select Settings & License.
2. Double-click the name of your product (Adams Car).
3. Select Preferences.
4. To the right of siteDir, in the Value column, enter (or right-click to browse for) a directory path, such as d:\acar_custom.
5. Select Apply or OK.

Defining Private Repositories

To define the private repository in Linux:

In Adams Toolbar, change the privateDir setting in the Adams Car preferences. For example, change it to:
/usr/people/someone/new_private
You can also change the privateDir setting using the Registry Shell Tool from the command line. For example, at the command line enter:
adams2024_1 -c rtool
set /MDI/ACar/Preferences/privateDir /usr/people/someone/new_private

To define the private repository in Windows:

1. From the Start menu, point to Programs, point to Adams 2024.1, and then select Settings & License.
2. Double-click the name of your product (ACar).
3. Select Preferences.
4. To the right of siteDir, in the Value column, enter (or right-click to browse for) a directory path, such as d:\acar_custom.
5. Select Apply or OK.
For more information on the directories, creating the binaries and libraries, and the Adams Toolbar, see Running and Configuring Adams.