Functions E-L

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

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

EQUIV

Function:

var1 = EQUIV(var2)

Action:

This function checks whether the variable var2 is equal to the variable var1; these two variables, which have different names, refer to the same numerical value.

Related variables: none

Macro call: No

Example: GETVAR macro for the NUM2APT postprocessor; this returns the value of an L or E variable.

$$ 
IF ( ARG1.val[2] = 21 ) name = "L" + FORMAT(2,ARG1.val[1]) IF
( ARG1.val[2] = 22 ) name = "E" + FORMAT(2,ARG1.val[1])
variable = EQUIV(name)
$$
RETURN / variable
EVALVEC

Function:

vec = EVALVEC ( p1 , p2 , p3 , rad , opt )

Action:

Calculates a tangent circle with radius rad to the two vectors (p1, p2) and (p2, p3).

  • If opt = 0: returns the center of the circle
  • If opt = 1: returns the axis of the circle
  • If opt = 2: returns the starting point (the point lies on the vector p1, p2)
  • If opt = 3: returns the ending point (the point lies on the vector p2, p3)

Related variables: none

Macro call: no

EXIST

Function:

val = EXIST(filename)

Action:

Checks whether a directory or file exists. Val = 1 if the file exists, Val = 0 if the file does not exist.

Related variables: none

Example:

file_info = FILOUT.dir + FILOUT.name + ".info"
IF ( EXIST(file_info) ) DELETE / file_info
FACTOR

Function:

val = FACTOR ( code )

Action:

Returns the value corresponding to the number of decimal places specified by the code.

  • If the number of decimal places is 1, the result is 10.
  • If 2, the result is 100.
  • If 3, the result is 1000.
  • If 4, the result is 10000.
  • If the code does not exist, the result is 1.

Related variables: none

FEDVAR

Function:

val = FEDVAR ( fedrat )

Action:

Retrieves the index of the fedrat advance in the FEDLST.val advance table.

Related variables:

  • FEDLST.val: advance array
  • FEDLST.start: initial search index
  • FEDLST.max: array size

Example: FCODE macro for parameterized feeds.

$$
IF ( ETAT0.fedmod = 2 ) THEN
  IF ( mactype = 760 ) THEN
    CODE.used[18] = 30
    IF ( FEDLST.on ) CODE.used[18] = 29
  ELSE
    CODE.used[18] = 25
    IF ( FEDLST.on ) CODE.used[18] = 19
  ENDIF
  FCODE
  RETURN
ELSE IF ( ETAT0.fedmod = 3 )
  FCODE
  RETURN
ELSE IF ( MODE.inverse = 1 )
  ETAT0.fedrat = 0
  IF ( mactype = 760 ) THEN
    CODE.used[19] = 31
    IF ( FEDLST.on ) CODE / 34 , 0.0
  ELSE
    CODE.used[19] = 25
    IF ( FEDLST.on ) CODE / 33 , 0.0
  ENDIF
  IF ( FEDLST.on ) THEN
    text = "L129=L" FORMAT(2,FEDVAR(FEDRAT.upm)) WRITE
    / text "*" FORMAT(6,ARG1.val[1]/FEDRAT.upm) ENDIF
  RETURN
ENDIF
$$
FORMAT

Function:

string = FORMAT ( val1 , val2 )

Action:

Writes the value of val2 into the string 'string' in the format val1 defined in the 'data' file.

Related variables: none

Example: Excerpt from the INIT macro for MAHO.

$$
number = STRVAL(PART.no) IF
( number = 0 ) number = 1
number = 9000 + number WRITE
/ "%PM"
WRITE / "N" FORMAT(2,number)
PPRINT / MACHINE = MAHO
$$
GCODE

Function:

val2 = GCODE ( val1 )

Action:

Retrieves the generic code for the G-code defined in the data file: gcode = val2, val1

Related variables: GCODE.val[].

GETDATA

Function:

data = GETDATA ( name )

Action:

Retrieves the name of the data file defined in the .def file (sgpost.def) under the ‘name’ field, which can take the following values: DATA, DATALIB, or DATAGEN. If name is different from any of these values, the function returns an empty string with an error.

Related variables: none

GETDIR

Function:

dir = GETDIR ( name )

Action:

Retrieves the directory defined in the .def file (sgpost.def) under the ‘name’ field, which can take the following values: GLOBAL, MACLIB, MACGEN, APT, NCTAPE, or CLFILE. If name is not one of these values, the function returns an empty string with an error.

Related variables: none

GETENV

Function:

string2 = GETENV ( string1 )

Action:

Retrieves the character string corresponding to the DOS or UNIX environment variable string1, which can be viewed using the PRINTENV, SET, or SETENV commands.

Related variables: none

GETFILE

Function:

string = GETFILE ( n )

Action:

Returns the filename of the nth selection; if n is greater than the number of selected files, an empty string of length 0 is returned.

Related variables: SGP.nfile: number of selected files

GETGCOM

Function:

string = GETGCOM(n)

Action:

Retrieves the character string corresponding to the comment for code G(n). This string is defined either in the data file using the statement ‘gcom = n, string’ or using the statement ‘SETGCOM / n, string’.

Related variables: none

GETMCOM

Function:

string = GETMCOM(n)

Action:

Retrieves the character string corresponding to the comment for code M(n). This string is defined either in the data file using the statement ‘mcom = n, string’ or using the statement ‘SETMCOM / n, string’.

Related variables: none

GETOOL

Function:

tool = GETOOL( n )
tool = GETOOL( 0 , string )

Action:

Retrieves the index of the tool in the TOOLIB library. The tool is identified by its number or name. Returns 0 if the tool does not exist.

Related variables:

  • TOOLIB.num[]
  • TOOLIB.ref[]

IJK

Function:

val = IJK(a, b, c)
val = IJK(a, b, c, mode)

Action:

Calculates the tool vector in the workpiece coordinate system based on the machine angles (a, b, c). The calculation of the angles takes into account the kinematics declared in the controller file. Val must be a 3-dimensional array.

  • If mode = 0, the spindle orientation is not taken into account for the IJK calculation.
  • If mode = 1 or is omitted: the spindle orientation is taken into account for the calculation of IJK.

Related variables: AXE0, AXE1, AXE2.

Example: excerpt from the GOTO macro for the XZC postprocessor

$$ Motion generation
$$$
ijk = IJK( 0.0 , 0.0 , 0.0 )
STATE0.xyzabc[4] = a0
pts = PTS( x0 , 0 , z0 )
UPDATE / OFF
dist = ABS( pts[1] - pts1[1] )
IF ( dist > dist_g60 ) THEN IF
( precis ) GCODE / 61 precis
= 0
ELSE
  IF ( precision = 0 ) GCODE / 60.0
  precision = 1
ENDIF
GOTO / pts[1], pts[2], pts[3], ijk[1], ijk[2], ijk[3] inverse =
ETAT0.fedrat / 60.0
IF ( ETAT0.fedmod = 1 ) CODE / 24 , inverse
UPDATE
UPDATE / ON
$$
ISCODE

Function:

test = ISCODE ( code )

Action:

Checks whether the code exists in the data file and returns the associated MAJOR number.

  • test = 0 the code does not exist
  • test = -1 the code exists but has no associated macro
  • test > 0 The code exists, and test defines the MAJOR number of the associated macro

Related variables: none

ISOCODE

Function:

code = ISOCODE ( pos )

Action:

Retrieves the code number at a given position in the current block of the ribbon file.

Related variables: none

Example: OPER macro for converting from NUM to APT

$$
ncode = ISODEF(1)
IF ( ISOPOS(1,ncode) < ARG1.val[4] ) RETURN
$$
code = ISOCODE(ARG1.val[4]-1) val
= ISOVAL(-1,ARG1.val[4]-1)
IF ( code = 21 ) name = "L" + FORMAT(2,val) IF
( code = 22 ) name = "E" + FORMAT(2,val)
$$
oper_val = EQUIV(name)
IF ( ARG1.val[2] = 60 ) THEN $$ =
  IF ( oper_val = ARG1.val[1] ) POSITN / ISOVAL(1,ncode) ELSE
IF ( ARG1.val[2] = 61 ) $$ <
  IF ( oper_val = ARG1.val[1] ) POSITN / ISOVAL(1,ncode) ELSE
IF ( ARG1.val[2] = 62 ) $$ <=
  IF ( oper_val <= ARG1.val[1] ) POSITN / ISOVAL(1,ncode)
ELSE IF ( ARG1.val[2] = 63 ) $$ >=
  IF ( oper_val >= ARG1.val[1] ) POSITN / ISOVAL(1,ncode)
ELSE IF ( ARG1.val[2] = 64 ) $$ >
  IF ( oper_val > ARG1.val[1] ) POSITN / ISOVAL(1,ncode) ELSE
IF ( ARG1.val[2] = 65 ) $$ <>
  IF ( oper_val # ARG1.val[1] ) POSITN / ISOVAL(1,ncode)
ENDIF
$$
ISODEF

Function:

ncode = ISODEF ( code )
pos = ISODEF ( code , val)

Action:

Inverse postprocessor with a single argument:

Retrieves the number of codes of a given type contained in the current block of the ribbon file.

Forward postprocessor with a single argument:

Retrieves the number of codes of a given type contained in the output buffer, i.e., the list of codes that will be written to the ribbon file at the next EOB.

With two arguments:

Retrieves the position of the code with a given value in the current block for the reverse postprocessor, or in the output buffer for the direct postprocessor. If pos = 0, the code with that value does not exist in the block.

Related variables: none

Example: see INDEX, example of G77

ISONAME

Function:

name = ISONAME(code,val)

Action:

  • If 1 argument: Returns the name of the code defined by its number (code).
  • If 2 arguments: Returns the name of the code defined by its number (code) and its value (val).

Related variables: none

ISOPOS

Function:

pos = ISOPOS ( code , icode )

Action:

Retrieves the position of a code of a given type in the current block of the ribbon file.

  • code = code number
  • icode = code index, if the block contains multiple identical codes.

Related variables: none

Example: See the ISOCODE and INDEX example.

ISOVAL

Function:

  • Reverse postprocessor: val = ISOVAL (code, n)
  • Direct postprocessor: val2 = ISOVAL (format, val1)

Action:

Inverse postprocessor: Retrieves the nth value of a code from the current block in the ribbon file. If code = -1, n represents the actual position of the code within the block.

Direct postprocessor: Retrieves the rounded value using the format: this value allows you to obtain the exact numerical value written in the ISO file

Related variables: none

Example: Excerpt from the GCODE macro, cycle decoding for the NUM-to-APT converter

ELSE IF ( ( ARG1.val[1] > 81 ) & ( ARG1.val[1] < 89 ) )
  $$
  ETAT0.move = 1
  cycle = ARG1.val[1] - 80
  WRITE / "CYCLE / " + cycle + " , FEDTO , 0.0 " + CHAR(36)
  $$
  IF ( ISODEF(16) ) WRITE / " , INCR , " + ISOVAL(16,1) + " " + CHAR(36) IF (
  ISODEF(17) ) WRITE / " , " + ISOVAL(17,1) + " " + CHAR(36)
  IF ( ISODEF(19) ) WRITE / " , DWELL , " + ISOVAL(19,1) + " " + CHAR(36) IF (
  ISODEF(18) ) WRITE / " , RAPTO , " + ISOVAL(18,1)
  $$

Example: Excerpt from the SGAXIS macro, used to determine the angles actually written to the result file for greater precision in defining the inclined plane.

$$
$$ part reference plane
$$
IF ( AXE1.type0 ) THEN
  IF (ABS(AXE1.ijk[AXE1.axe-2]) = 1.0 ) THEN
    PLAN.abc = ABC(ARG1.val[1],ARG1.val[2],ARG1.val[3],0)
  ELSE
    PLAN.abc = PLANABC(ARG1.val[1], ARG1.val[2], ARG1.val[3]) ENDIF
ELSE
  PLAN.abc = PLANABC(ARG1.val[1], ARG1.val[2], ARG1.val[3])
ENDIF
PLAN.xyz = XYZ(PLAN.pts[1], PLAN.pts[2], PLAN.pts[3])
$$
$$ ISO value for greater precision
$$
PLAN.abc[1] = ISOVAL(1,PLAN.abc[1])
PLAN.abc[2] = ISOVAL(1,PLAN.abc[2])
PLAN.abc[3] = ISOVAL(1,PLAN.abc[3])
$$
LABEL

Function:

val = LABEL(code, n, direction)

Action:

Reverse postprocessor only.

Moves to the first line of the file containing the address code ‘code’ with value n.

Val = 0 if the code was not found; otherwise, the line number.

  • If code = -1, the function positions itself at the INDEX with number n
  • If direction = 0, the function places the decoding before the line containing the code.
  • If direction = 1, the function places the decoding after the line containing the code.
  • If direction = -1, the function positions the decoding after the line defining the jump.

Related variables: none

Example: Excerpt from the MCODE macro, subprogram decoding for FANUC

ELSE IF ( ARG1.val[1] = 98 ) $$ M98
  $$
  IF ( ISODEF(39) ) THEN $$ Pn
    label = ISOVAL(39,1)
    IF ( LABEL(24,label,0) ) THEN $$ set to On PRINT " label
      " label " type 24"
    ELSE IF ( LABEL(25,label,0) ) $$ set to :n PRINT
      "label" label "type 25"
    ELSE
      ERROR "label " label not found"
    ENDIF
  ENDIF
LIMANGLE

Function:

val = LIMANGLE ( val1 , axis )
or
val = LIMANGLE( val1, min, max )

Action:

Rounds the angular value val1 to the nearest multiple of 360° within the defined limits mini and maxi, or within the machine limits of a specific rotary axis. If maxi - mini < 360, there may be no solution; in this case, val = val1.

axis = 4 or 5 or 6

Related variables:

  • LIMIT.min[9]: minimum machine travel
  • LIMIT.max[9]: maximum machine travel

Example: see NEXTABC

LIMAXE

Function:

error = LIMAXE ( val , axis , print )

Action:

Used to test the limits of a machine axis.

  • if val < LIMIT.min[axis] → error = -1
  • if LIMIT.min[axis] <= val <= LIMIT.max[axis] → error = 0
  • if val > LIMIT.max[axis] → error = 1

  • If print = 1, the error message is displayed and the error is added to the error list.
  • If print = 0, no message

Related variables:

  • LIMIT.min[9]: minimum machine stroke
  • LIMIT.max[9]: maximum machine stroke

Example: excerpt from the GOTO file

IF ( ARG1.nval = 6 ) THEN
  ijk = VEC(ARG1.val[4],ARG1.val[5],ARG1.val[6])
ELSE
  ijk = VEC(ETAT1.pts[4],ETAT1.pts[5],ETAT1.pts[6])
ENDIF
STATE0.xyzabc[4] = ABC(ijk[1],ijk[2],ijk[3])
ETAT0.xyzabc[4] = POLAR(ARG1.val[1],ARG1.val[2],ARG1.val[3])
$$
$$ Reversal and Limits
$$
IF ( (AXE0.type = 1) & (AXE1.type = 1) & (AXE0.law = 0) ) THEN
  IF ( LIMAXE(AXE0.axe+1,ETAT0.xyzabc[AXE0.axe+1],0) ) RETURN
ENDIF
IF ( LIMAXE(4,ETAT0.xyzabc[4]) ) EXIT $$ limit A IF (
LIMAXE(5,ETAT0.xyzabc[5]) ) EXIT $$ limit B IF (
LIMAXE(6,ETAT0.xyzabc[6]) ) EXIT $$ limit C
$$
LIMIT

Function:

val = LIMIT ( axis , major, polar)

Action:

Returns the displacement extrema for an axis from the current position to the major word whose number is equal to major.

  • If major = 0 or undefined, the LIMIT function stops at SGROT.
  • If polar = (0, 1, 2, 3, 4) or undefined: the polar mode is taken into account when calculating travel distances.

Polar = 0: no polar mode Polar =
1: rotation around X Polar = 2:
rotation around Y Polar = 3:
rotation around Z
Polar = 4: rotation around the1strotary axis

axis = 0 for all axes axis =
1 for XCODE axis = 2 for
YCODE axis = 3 for
ZCODE
axis = 4 for ACODE;
axis = 5 for BCODE;
axis = 6 for CCODE

if axis = 0
  val[1] = minimum X axis
  val[2] = maximum X axis
  val[3] = minimum Y axis
  …………………………
  val[12] = maximum C-axis value
else
  val[1] = minimum
  val[2] = maximum

Related variables:

  • AXE0, AXE1, AXE2
  • POLAR MODE

Example: excerpt from the SGROT file for managing the C axis travel

$$
$$ travel c1
$$
ntour = 0STATE1.xyzabc[4] = VEC(abc1[1], abc1[2], abc1[3])
c1 = LIMIT(axis0+3)
IF ( c1[1] < LIMIT.min[axis0+3] ) THEN
  ntour = AINT((-1*c1[1] + LIMIT.min[axis0+3]) / 360.0) + 1
  abc1[axis0] = abc1[axis0] + ntour*360.0 PRINT
" position1 - " c1[1] " " c1[2] " " ntour ELSE IF (
c1[2] > LIMIT.max[axis0+3] )
  ntour = AINT((c1[2] - LIMIT.max[axis0+3]) / 360.0) + 1
  abc1[axis0] = abc1[axis0] - ntour*360.0 PRINT
" position1 + " c1[1] " " c1[2] " " ntour ENDIF
$$
LOWER

Function:

string2 = LOWER( string1 )

Action:

Converts string1 to lowercase 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
$$