Transformations

transRotX/Y/Z

transRotX(angle := LREAL)

transRotY(angle := LREAL)

transRotZ(angle := LREAL)

Rotation around the respective axis by the given angle in the user-defined angle unit. The rotation is pushed onto the stack of transformations. The angle value is interpreted using the current angle-unit. See section Transformations for details.

Example:

The resulting path of the following example is shown in Figure “ExampleTransRotZ”.

N10 G01 X30 Y0 F6000
!transRotZ(45);
N20 G01 X30 Y0
!transRotZ(45);
N30 G01 X30 Y0
!transPop();
!transPop();
M02
Transformations 1:

Figure “ExampleTransRotZ”.

transRotA

transRotA(x:=LReal, y:=LReal, z:=LReal, angle:=LReal)

Rotate around vector [x,y,z] by the given angle. The rotation is pushed onto the stack of transformations. The angle value is interpreted using the current angle-unit. See section Transformations for details.

Transformations 2:

The vector [x,y,z] must not be the zero vector.

Example:

The resulting path of the following example is shown in Figure “ExampleTransRotA”. The first invocation of transRotA rotates the PCS (program coordinate system) around the positive Z-axis (right-hand rule) by 45 degree. The second invocation rotates around the negative Z-axis by the same angle, i.e. into the opposite direction. The combination of both rotations is the identity transformation.

!transRotA(0,0,1,45);
N10 G01 X30 Y0 F6000
!transRotA(0,0,-1,45);
N20 G01 X30 Y0
!transPop();
!transPop();
M02
Transformations 3:

Figure “ExampleTransRotA”.

transMirrorX/Y/Z

transMirrorX()

transMirrorY()

transMirrorZ()

Mirror with respect to the X-direction, Y-direction or Z-direction relative to the origin of the current PCS (program coordinate system). The transformation is pushed onto the stack of transformations.

Transformations 4:

The invocation of a mirror function switches the orientation of the coordinate system from right-handed to left-handed or vice versa. Most notably, this behavior switches the rotation direction of circles and the compensation direction of tool radius compensation. By default, the coordinate system is right-handed.

Example:

The resulting path of the following example is shown in Figure “ExampleTransMirrorX”. The PCS (program coordinate system) is mirrored along the X-dimension. Thereby, the coordinate system becomes a left-handed system, within which the rotation direction of G2 is (intentionally) swapped.

N10 G02 X20 Y20 U20 F6000
!transMirrorX();
N20 G02 X-40 Y0 U20
!transPop();
M02
Transformations 5:

Figure “ExampleTransMirrorX”.

transScale

transScale(factor:= LReal)

Scales the coordinate system by the factor in the X-dimension, Y-dimension and Z-dimension. The transformation is pushed onto the stack of transformations.

Transformations 6:

The factor must be nonzero.

Transformations 7:

If the factor is negative, the coordinate system is effectively mirrored in the X-dimension, Y-dimension and Z-dimension. Thus, the orientation of the coordinate system is swapped.

Example:

The resulting path of the following example is shown in Figure “ExampleTransScale”. After scaling by a factor of 2, the endpoint of segment N20 is mapped to [60,20,0].

N10 G01 X30 Y10 F6000
!transScale(2);
N20 G01 X30 Y10
!transPop();
M02
Transformations 8:

Figure “ExampleTransScale”.

transScaleAxis

transScaleAxis(axisNo := axisIndex, factor := value);

Scales the selected path axis (axisNo) by the factor. The supported axis and indexes are:

Q-axes are not supported.

Transformations 9:

A different axes scaling is only allowed for linear movements, not for circular movements.

Example 1

N10 G01 X30 Y10 F6000
!transScaleAxis(axisNo:= 0, factor:=2.0);
!transScaleAxis(axisNo:= 1, factor:=2.0);
!transScaleAxis(axisNo:= 2, factor:=3.0);
N20 G01 X30 Y10
N30 G03 X40 Y10 I5 J0
M02
Transformations 10:

Figure “Example 1 TransScaleAxis”.

Example 2

N10 G01 X20 Y5 F6000
!transScaleAxis(axisNo:= 0, factor:=2.0);
!transScaleAxis(axisNo:= 1, factor:=2.0);
!transScaleAxis(axisNo:= 2, factor:=3.0);
N20 G01 X20 Y5
!transScaleAxis(axisNo:= 0, factor:=2.0);
!transScaleAxis(axisNo:= 1, factor:=3.0);
N30 G01 X20 Y5
M02
Transformations 11:

Figure “Example 2 TransScaleAxis”.

Requirements

Development Environment

Target System

TwinCAT V3.1.4024.20

PC or CX (x86 or x64)

transTranslate

transTranslate(x:=LReal, y:=LReal, z:=LReal)

Translate by vector [x,y,z]. The translation is pushed onto the stack of transformations.

Example:

The resulting path of the following example is shown in Figure “ExampleTransTranslate”. After translating by [40,20,0] the endpoint of segment N20 is mapped to [80,20,0].

N10 G01 X20 Y0 F6000
!transTranslate(40,20,0);
N20 G01 X40 Y0
!transPop();
M02
Transformations 12:

Figure “ExampleTransTranslate”.

transPop

transPop()

Pops a transformation from the stack of transformations.

Example:

The resulting path of the following example is shown in Figure “ExampleTransPop”. This example pushes the translation [0,20,0] onto the stack, followed by the translation [0,10,0]. Thereby, the effective translation for N30 is [0,30,0]. The invocation of transPop removes the translation [0,10,0] from the stack. Thus, the endpoint of segment N40 is translated by [0,20,0]. After removing the last translation from the stack the endpoint of segment N50 is not translated at all.

N10 G01 X10 Y0 F6000
!transTranslate(0,20,0);
N20 G01 X30 Y0
!transTranslate(0,10,0);
N30 G01 X50 Y0
!transPop();
N40 G01 X70 Y0
!transPop();
N50 G01 X90 Y0
M02
Transformations 13:

Figure “ExampleTransPop”.

transDepth

transDepth(): UInt

Yields the depth of the stack of transformations, i.e. the number of active transformations. See transRestore(…), chapter transformations, for more details.

transRestore

transRestore(depth:= UInt)

Reduces the stack of transformations to the given depth. This command is typically used in conjunction with transDepth() to restore an earlier state of the stack.

Transformations 14:

The current depth of the stack must not be smaller than the given depth.

Example:

The resulting path of the following example is shown in Figure “ExampleTransDepthTransRestore”. A translation to [40,10,0] is initially pushed onto the transformation stack. The resulting depth is stored in variable savedDepth. The following code repeatedly performs a linear move to X20 Y0 and a rotation by 45 degree. This resulting path is one half of an octagon, composed of segments N10 to N50. When N50 is processed, the transformation stack contains the initial translation and 4 rotations by 45 degree. The invocation of transRestore(savedDepth) restores the stack depth of 1 by removing all rotations. Hence, only the translation is applied to N60.

!VAR savedDepth : UINT; END_VAR
!transTranslate(40,10,0);
!savedDepth := transDepth();

N10 G01 X20 Y0 F6000
!transRotZ(45);
N20 G01 X20 Y0
!transRotZ(45);
N30 G01 X20 Y0
!transRotZ(45);
N40 G01 X20 Y0
!transRotZ(45);
N50 G01 X20 Y0
!transRestore(savedDepth);
N60 G01 X10 Y0
M02
Transformations 15:

Figure “ExampleTransDepthTransRestore”.