Functions R-X

This section provides basic information about the Functions for DELMIA SGPost processor.

Most of the examples are taken from the standard postprocessors provided.

READ

Function:

string1 = READ ( string2 )

Action:

Writes characters entered from the keyboard into the string 'string1' and displays the string 'string2' on the console screen. Allows the operator to enter text information.

Related variables: none

Macro call: No

Example: Excerpt from the INIT macro for AGIE (SBL)

$$
text = READ("Part thickness?") thickness
= STRVAL(text)
IF ( thickness <= 0 ) thickness = 10
$$
RENAME / UPPER(SGP.output[1,8]) + ".SBL"
OPEN1 / UPPER(SGP.output[1,8]) + ".SBR"
version = "AGIE.VERSION 4,02.03.00;"
WRITE1 / version
WRITE1 / ".LONGNAME " SGP.output ";"
$$
READF

Function:

text = READF ( n)

Action:

Reads the nth line from the file opened with OPENR. If n = 0, reads the next line.

The variable RUBAN.eof is specifed to 1 if the end of the file has been reached.

Related variables: RUBAN.eof

Macro call: No

Example: Searching for tool information in a tool table

OPENR / tool_data_file #lab10
text = READF(0)
IF ( RUBAN.eof ) THEN
  ERROR "The tool does not exist in the tool table"
ENDIF
IF ( RUBAN.eof ) JUMPTO lab20
  text1 = STRXGET(text, 1, ";")
  IF ( ARG1.val[1] # STRVAL(text1) ) JUMPTO lab10
  $$
  text1 = STRXGET(text, 2, ";")
  len1 = STRLEN(text1)
  CUTTER.ref = text1[2, len1 - 1]
  $$
  text1 = STRXGET(text, 3, ";")
  len1 = STRLEN(text1)
  CUTTER.att = text1[2, len1 - 1]
$$
#lab20
READN

Function:

line = READN(n)

Action:

Reads the nth line from the open file. If n = 0, reads the next line.

The line variable is empty if the end of the file has been reached

Related variables: none

Macro call: no

Example: Excerpt from the GOTO file of a reverse postprocessor NUM2APT

$$
IF (cycle) THEN
  CYCLE / cycle, FEDTO, ARG1.val[3]
ELSE
  line = READN(1)
  IF ( STRSTR(line, "H9978" ) ) THEN
    CYCLE / 38
  ELSE IF ( move & (STATE0.move = 0) )
    WRITE / "RAPID"
  ENDIF
ENDIF
$$
SARG

Function:

val = SARG(minor)

Action:

Checks whether the minor ‘minor’ exists after a search

Related variables: none

Example: excerpt from the LOADTL file for Heidenhain

$$
SEARCH / ON
M_spindl = MAJOR("SPINDL")
M_loadtl = MAJOR("LOADTL")
SEARCH / M_spindl, M_loadtl
IF ( SARG.num = M_spindl ) THEN
  value = SARG("VALUE")
  nvalue = SNVAL("VALUE")
  rpm = SARG("RPM")
  nrpm = SNVAL("RPM")
  IF ( value & nvalue ) SPINDL.val = SVAL("VALUE",1)
IF ( rpm & nrpm ) SPINDL.val = SVAL("RPM",1)
ENDIF
$$
SIN

Function:

val1 = SIN(val2)

Action:

Calculates the sine of val2 in degrees.

Related variables: none

SNVAL

Function:

n = SNVAL(minor)

Action:

Returns the number of numeric values following the minor after a search

Related variables: none

Example: For SPINDL / RPM, with 1000 in the SPINDL macro, SNVAL("RPM") = 1; see SARG

SPINVAL

Function:

val = SPINVAL(axis, vx, vy, vz)

Action:

Obtains the orientation angle of the vector (vx, vy, vz) in the spindle coordinate system defined by the rotation angles abc.

Axis = rotation axis: 0=Z, 1=X, 2=Y, 3=Z, -1=-X, -2=-Y, -3=-Z

Related variables:

STATUS0.xyzabc[4-6]: positions of the rotary axes AXIS0, AXIS1, AXIS2.

SQRT

Function:

val1 = SQRT(val2)

Action:

Calculates the square root of val2.

Related variables: none

STRCMP

Function:

test = STRCMP(string1, string2)

Action:

Comparison of two character strings. test = 0 if the strings are identical; this is obsolete and can be replaced by the ‘=’ operator

Related variables: none

Example: COMMENT macro, decoding the tool diameter

IF ( STRCMP(ARG0[4,9],"CUTTER") = 0 ) THEN
  diameter = STRVAL(ARG0[12,25])
  TOOLIB / LOADTL.num, diameter
ENDIF

Equivalent to:

IF ( ARG0[4,9] = "CUTTER" ) THEN
  diameter = STRVAL(ARG0[12,25])
  TOOLIB / LOADTL.num, diameter
ENDIF
STREVAL

Function:

val = STREVAL ( string )

Action:

Retrieves the value contained in the character string. In reverse post-processing, this string may contain calculation instructions with variables. For example, 1+2*R1 (Siemens format).

Related variables: none

STRGET

Function:

text = STRGET ( string , n)

Action:

Retrieves the nth word from string. Each word is separated by ‘ ’, ‘=’, ‘,’ or ‘:’

Related variables: none

Example:

text = " tool: FR10, diameter = 10 "
STRGET(text,1) is ‘tool’
STRGET(text,2) is ‘FR10’
STRGET(text,3) is ‘diameter’
STRGET(text,4) is ‘10’
STRLEN

Function:

val = STRLEN(string)

Action:

Returns the length of a string, that is, the number of characters.

Related variables: none

STRFMT

Function:

string = STRFMT ( string1 , pos , string2 )

Action:

Appends string2 to the end of string1 at a specified position.

  • If pos > 0, this is the position in string1 of the first character of string2.
  • If Pos < 0, position in string1 of the last character of string2.
  • If Pos < the length of string1, then string = string1 + string2.

Related variables: none

STRSTR

Function:

index = STRSTR(string1, string2)

Action:

Searches for string2 in string1 and returns the index of the first character of string2 in string1

Related variables: none

STRVAL

Function:

val = STRVAL ( string )

Action

Retrieves the value contained in the character string.

Related variables: none

Example: see STRCMP

STRXGET

Function:

text = STRXGET ( string , n , string1 )

Action:

Retrieves the nth word from string. Each word is separated by one of the characters in string1

Related variables: none

Example:

text = " tool: FR10, diameter = 10 "
STRXGET(text,1,":,") returns ‘tool’              
STRXGET(text, 2, " :,=" ) returns ‘FR10’
STRXGET(text,3," :,=" ) returns
‘diameter’ STRXGET(text,4," :,=" )
returns ‘10’

Example: See READN, decoding the result of READN.

SVAL

Function:

val = SVAL(minor) val = SVAL(minor,n)

Action:

Retrieves the nth value following the keyword after a search. If n is not specified, SVAL returns the first value.

Related variables: none

Example: see SARG

TAN

Function:

val1 = TAN(val2)

Action:

Calculates the tangent of val2 in degrees.

Related variables: none

UPPER

Function:

string2 = UPPER( string1 )

Action:

Converts string1 to uppercase ASCII characters.

Related variables: none

Example: Excerpt from the INIT file for HEIDENHAIN

$$
SEARCH / ALL
$$
WRITE "0 BEGIN PGM " + UPPER(SGP.output) + " MM"
name = LOWER(SGP.output) + ".h"
RENAME / name
$$
VAL

Function:

val = VAL(minor) val = VAL(minor,n)

Action:

Retrieves the nth value following the word “minor.” If n is not specified, VAL returns the first value.

Example for CYCLE / DRILL, 10, 1000

In the CYCLE macro:

VAL("DRILL", 1) = 10
VAL("DRILL", 2) = 1000

Related variables: none

Example: Excerpt from the CYCLE macro

ELSE IF ( ARG("DRILL") )
  CYCLE.on = 1
  CYCLE.mode = 1
  CYCLE.idwell = 0
  CYCLE.irapto = 0
  CYCLE.irtrcto = 0
  CYCLE.iincr = 0
  IF ( NVAL("DRILL") ) THEN
    CYCLE.ifedto = 1
    CYCLE.fedto = -1*VAL("DRILL",1)
  ENDIF
  IF ( NVAL("DRILL") = 2 ) THEN
    CYCLE.irapto = 1
    CYCLE.rapto = VAL("DRILL", 2)
  ENDIF
VALAXE

Function:

val1 = VALAXE(val2, incr)

Action:

Find the value of val1 closest to val2 that is a multiple of incr: Val1 = n*val2, such that –incr/2 < val1 – val2 < incr/2.

Used to best determine the value of an indexed rotary axis

Related variables: none

$$
abc = ABC(ARG1.val[1],ARG1.val[2],ARG1.val[3])
abc[1] = VALAXE(abc[1],1.0)
abc[1] = LIMANGLE(abc[1], 0, 360)
abc[2] = ISOVAL(1, abc[2])
abc[3] = VALAXE(abc[3], 1.0)
abc[3] = LIMANGLE(abc[3], -180, 180)
$$

Example: Calculating the 3 angles of the rotational axes

VEC

Function:

v = VEC(x, y, z)

Action:

Initialization of a vector: v[1] = x, v[2] = y, v[3] = z

Related variables: none

VECADD

Function:

v = VECADD(v1, v2)

Action:

Addition of two vectors v =

v1 + v2 v[1] = v1[1] + v2[1] v[2] = v1[2] + v2[2] v[3] = v1[3] + v2[3]

Related variables: none

VECDIFF

Function:

v = VECDIF(v1,v2)

Action:

Difference between two vectors v =

v1 – v2 v[1] = v1[1] – v2[1] v[2] = v1[2] – v2[2] v[3] = v1[3] – v2[3]

Related variables: none

VECLEN

Function:

l = VECLEN(v)

Action:

Length of a vector l = sqrt( v[1]*v[1] + v[2]*v[2] + v[3]*v[3] )

Related variables: none

VECLEN1

Function:

l = VECLEN1(v1, v2)

Action:

Length of the difference between two vectors

l = sqrt((v1[1]–v2[1])*(v1[1]–v2[1]) + v1[2]–v2[2])*(v1[2]–v2[2]) + v1[3]–v2[3])* (v1[3]–v2[3]))

Related variables: none

VECLIN

Function:

v = VECDIF(v1, a, v2)
  • v1 = Origin vector of the line
  • v2 = Direction vector of the line

Action:

Coordinate vector of a point on a line

v[1] = v1[1] + a*v2[1] v[2] = v1[2] + a*v2[2] v[3] = v1[3] + a*v2[3]

Related variables: none

Example: see XYZ

VECPS

Function:

proj = VECPS(v1,v2)

Action:

Scalar product of two vectors: proj = v1 * v2 proj

= v[1]*v[1] + v[2]*v[2] + v[3]*v[3]

Related variables: none

VECPV

Function:

v = VECPV(v1, v2)

Operation:

vector product: v = v1 ^ v2.

v[1] = v1[2]*v2[3] – v1[3]*v2[2] v[2] = v1[3] * v2[1] – v1[1] * v2[3] v[3] = v1[1] * v2[2] – v1[2] * v2[1]

Related variables: none

VECROT

Function:

v = VECROT(v1, a, v2)

  • v1 = Rotation axis vector
  • v2 = Vector to be modified

Operation:

v = vector obtained by rotating vector v2 around axis v1 by an angle.

Related variables: none

XYZ

Function:

val1 = XYZ (val2, val3, val4)
val1 = XYZ(val2, val3, val4, val5)

Action:

Calculates the machine’s XYZ positions based on the tool’s position (val2, val3, val4) in the workpiece coordinate system. This position calculation takes into account the kinematics defined in the controller file, the reference point, and the TABLE inclined plane matrix. val1 must be a 3-dimensional array.

  • If val5 is not defined, the reference point is defined by MODE.pivot or MODE.xyz.
  • If val5 = 0: Tooltip; 1 = tool center; 2 = head pivot; 3 = spindle nose pivot.

Related variables:

  • AXE0, AXE1, AXE2,
  • TABLE, MODE

Example: excerpt from the GOCYCL macro

$$
fedto = VECLIN(ARG1.val, CYCLE.fedto, ETAT1.pts[4])
XYZ = XYZ ( fedto[1] , fedto[2] , fedto[3] )
rapto = VECLIN(ARG1.val, CYCLE.rapto, ETAT1.pts[4])
approach = XYZ( rapto[1] , rapto[2] , rapto[3] )
rtrcto = VECLIN(ARG1.val, CYCLE.rtrcto, ETAT1.pts[4])
retraction = XYZ( rtrcto[1] , rtrcto[2] , rtrcto[3] )
$$
XYZMAC

Function:

val1 = XYZMAC(val2, val3, val4)

Action:

Calculates the machine XYZ position based on the local XYZ position (val2, val3, val4) stored in the ISO file. This function calculates the actual machine travel distances, taking into account the kinematics, tool length, and the inclined plane.

xyzmac = XYZMAC(ETAT0.xyzabc[1], ETAT0.xyzabc[2], ETAT0.xyzabc[3])

The machine travel ranges LIMIT0.min and LIMIT0.max are calculated using this function.

Related variables:

  • AXE0, AXE1, AXE2
  • TABLE
  • CUTTER.h