Overview

The Generate class creates a string description of a process seen by an Adaptive object. To generate a G-code program, select the machine style and then traverse a STEP-NC process, stopping at each event, and print the string returned by the FormatEvent() function. It is easy to substitute your own logic for tool changes, program start, etc. Simply watch for the event and emit your own codes instead of the ones returned by the Generate object.

There are a variety of built-in styles: G-Code for Fanuc, Haas, Heidenhain, Okuma, Siemens style controls, five axis via TCP with IJK, AC, BC, or AB moves, Renishaw and native probing cycles, as well as other languages like APT, DMIS, or CRCL. Call SetStyle() to start with a base style and modify many different aspects of the output.

The formatting functions take an Adaptive object that holds the position in the process. They also take a GenerateState object that tracks the current commanded state of the machine tool axes and modal variables.

If you wish to augment the output with your own codes, the Cat* functions (CatNumber(), CatParam(), etc.) and Format* functions (FormatBlock(), FormatComment(), FormatOther(), FormatMoveXYZ(), etc.) can help you build codes quickly and flexibly.

The Generate class is available in both .NET and Node environments. The documentation for the STEP-NC Control Library describes a lower level C++ version of this API, and includes more background discussion.

Example

The example below reads a STEP-NC file and prints Haas-style codes for the process. It uses its own codes for the start of the program and tool changes. The tool change logic uses one of the utility functions provided by the class to print an informative tool change comment, but substitutes its own logic for the actual change.

This example uses the .NET API, a version using the Node API is in the following section

static void Main(string[] args)
{
    Finder finder = new Finder();
    Adaptive ctl = new Adaptive();
    Generate fmt = new Generate();
    GenerateState vars = new GenerateState();

    // Read a STEP-NC file
    finder.Open238("datafile.stpnc");

    // Start traversing the process within the file.   
    ctl.StartProject();
    ctl.SetWantedAll(true);

    fmt.SetStyle("okuma");
    fmt.SetUnitSystem(ctl);

    while (ctl.Next() != Adaptive.CtlEvent.DONE)
    {
	switch (ctl.Event())
	{
	    case Adaptive.CtlEvent.PROJECT_START:
		// print a comment and follow with our logic
		Console.Write(fmt.FormatComment(vars,"My great program"));
		Console.WriteLine("My program start logic here");
		break;
		
	    case Adaptive.CtlEvent.TOOL_CHANGE:
		// print a description of the tool and follow with our logic
		Console.Write(fmt.FormatOther(vars,ctl,"tool-comment"));
		Console.WriteLine("My tool change logic here");
		break;

	    default:
		Console.Write(fmt.FormatEvent(vars,ctl));
		break;
	}
    }
}

When run against a sample process, the program generates the following. The custom program start and tool change portions are highlighted.

(MY GREAT PROGRAM)
My program start logic here
(MSG,FACE TOP OF PART)
(WORKINGSTEP: LINE 33 WS 1)
(TOOL CHANGE: TOOL 1)
( DIAMETER: 25.4MM)
( CORNER RADIUS: 0.508MM)
( TAPER: 0DEG)
( TIP ANGLE: 0DEG)
My tool change logic here
M3S2000
M08
G0X0.Y0.Z-2.54
X-184.15Y143.51Z-55.88
Z-80.772
G1X-152.4F1016.
X152.4
Y124.46
X-152.4
[ ... and so on ... ]

If we change the style string from "haas" to "heidenhain", our program will produce rather different output:

; My great program
My program start logic here
; Workingstep: line 33 WS 1
; TOOL CHANGE: TOOL 1
;  diameter: 25.4mm
;  corner radius: 0.508mm
;  taper: 0deg
;  tip angle: 0deg
My tool change logic here
N1 S2000 M3
N2 M08
N3 G0 X0 Y0 Z-2.54 A0 C0
N4 X-184.15 Y143.51 Z-55.88
N5 Z-80.772
N6 G1 X-152.4 F1016
N7 X152.4
N8 Y124.46
N9 X-152.4
[ ... and so on ... ]

Example in Node

The example shown above can also use the Node.js binding:

const stp = require('../build/Release/StepNode');
const apt = new stp.AptStepMaker();
const finder = new stp.Finder();
const ctl = new stp.Adaptive();
const gen = new stp.Generate();
const genstate = new stp.GenerateState();

function main(argv) {

  // Read a STEP-NC file
  finder.OpenProject("datafile.stpnc");

  // Start traversing the process within the file.   
  ctl.StartProject();
  ctl.SetWantedAll(true);

  gen.SetStyle("okuma");
  gen.SetUnitSystem(ctl);

  while (ctl.Next() != stp.CtlEvent.DONE) {
    switch (ctl.Event())
    { 
      case stp.CtlEvent.PROJECT_START:
      // print a comment and follow with our logic
      // process.stdout.write(gen.FormatComment(genstate,"My great program"));
      process.stdout.write("My program start logic here\n");
      break;
      
      case stp.CtlEvent.TOOL_CHANGE:
      // print a description of the tool and follow with our logic
      process.stdout.write(gen.FormatOther(genstate,ctl,"tool-comment"));
      process.stdout.write("My tool change logic here\n");
      break;

      default:
      process.stdout.write(gen.FormatEvent(genstate,ctl));
      break;
    }
  }
  return 0;
}

process.exit(main(process.argv));

CatNumber()

System::String^ CatNumber(			
	System::String^ s,
	double num
	);
	
System::String^ CatNumber(
	System::String^ s,
	double num,
	System::Int64 max_digits,
	System::Int64 min_digits
	);


string CatNumber(				
	string s,
	double num
	int max_digits,		(optional)
	int min_digits		(optional)
	);

The CatNumber() function formats a floating point number as a string with a given maximum and minimum digits of precision. The result is concatenated to the end of the supplied string object and returned from the function.

CNC systems usually have a maximum number of digits, but some may also require a minimum number. A minimum digits value of -1 removes the trailing decimal point for integer values. If this is 0, the decimal point is retained.

If no max/min digits are given, the function uses the values from GetDigits() and GetMinDigits().

input 1.234567
max=5, min=-1 => 1.23457
max=2, min=-1 => 1.23

input 1.2
max=5, min=-1 => 1.2
max=2, min=0  => 1.2
max=2, min=2  => 1.20

input 1
max=5, min=-1 => 1
max=2, min=0  => 1.
max=2, min=2  => 1.00

CatParam()

System::String^ CatParam(				
	System::String^ s,
	System::String^ param
	);

System::String^ CatParam(
	System::String^ s,
	System::String^ param,
	double num
	);

System::String^ CatParam(
	System::String^ s,
	System::String^ param,
	double num,
	System::Int64 max_digits,
	System::Int64 min_digits
	);


string CatParam(					
	System::String^ s,
	System::String^ param
	double num,			(optional)
	System::Int64 max_digits,	(optional)
	System::Int64 min_digits	(optional)
	);

The CatParam() function appends a string for a parameter name and possibly a formatted number, separated by whitespace if the GetUseWhitespace() preference is true. This function is simply a more concise way equivalent to add optional whitespace, add the parameter string, and then a number formatted with CatNumber().

CatRequiredSpace()

System::String^ CatRequiredSpace (System::String^ s);	

string CatRequiredSpace (string s);			

The CatRequiredSpace() function is a low-level function used to construct formatted text. It appends whitespace to the end of a string if the original string is not empty. This function is used for separating parameters when whitespace is always required.

CatSpace()

System::String^ CatSpace (System::String^ s); 		

string CatSpace (string s);		 		

The CatSpace() function is a low-level function used to construct formatted text. It appends whitespace to the end of a string if the original string is not empty and if the GetUseWhitespace() flag is true. This function is used to separate parameters that may or may not have space between them, like coordinates in a G-code block.

FormatBlock()

System::String^ FormatBlock(				
	GenerateState^ vars,
	System::String^ str
	);


string FormatBlock(					
	GenerateState vars,
	string str
	);

The FormatBlock() function is a low-level function used to construct formatted text. This takes a string, adds a newline, and prepends a block number (eg. "N1234") if the GetUseBlocknums() flag is true. The block number is given by vars.GetNextBlocknum(). The function returns the resulting string.

FormatBlockNonum()

System::String^ FormatBlockNonum(			
	GenerateState^ vars,
	System::String^ str
	);


string FormatBlockNonum(				
	GenerateState vars,
	string str
	);

The FormatBlockNonum() function is a low-level function used to construct formatted text. This takes a string and adds a newline. It is used for things that must never have a block number. The function returns the resulting string.

FormatComment()

System::String^ FormatComment(				
	GenerateState^ vars,
	System::String^ str
	);

System::String^ FormatComment(
	GenerateState^ vars,
	System::String^ header,
	System::String^ str
	);


string FormatComment(					
	GenerateState vars,
	string header,
	string str		(optional)
	);

The FormatComment() function is a low-level function that encodes the input string as a comment in the manner appropriate for the output style. If two strings are given, they are concatenated with a colon separator as "header: str". The function returns an empty string if an empty input string is given.

The comment formatting may convert the strings to uppercase, strip unsupported characters, and wrap the string with delimiters.

FormatEvent()

System::String^ FormatEvent(				
	GenerateState^ vars,
	Adaptive^ cursor
	);


string FormatEvent(					
	GenerateState vars,
	Adaptive cursor
	);

The FormatEvent() function is the main process formatting function. This examines the most recent Event() in the cursor and calls one or more formatting functions to build a string that represents it. The function may return an empty string if nothing is needed.

Usually the cursor position is not changed, but sometimes formatting will advance the cursor. For example, when starting a probing operation, the formatting may iterate over the entire operation and return all of the moves necessary for the approach, touch and retract of the probe. The "vars" object is updated.

Finder finder = new Finder();
Adaptive ctl = new Adaptive();
Generate fmt = new Generate();
GenerateState vars = new GenerateState();

// Read a STEP-NC file
finder.OpenProject("sample.stpnc");

// Start traversing the process within the file.   
ctl.StartProject();
ctl.SetWantedAll(true);
fmt.SetStyle("okuma");
fmt.SetUnitSystem(ctl);

while (ctl.Next() != Adaptive.CtlEvent.DONE)
{
    Console.Write(fmt.FormatEvent(vars,ctl));
}

FormatMoveXYZ()

System::String^ FormatMoveXYZ(				
	GenerateState^ vars,
	Adaptive^ cursor,
	double x, double y, double z
	);


string FormatMoveXYZ(					
	GenerateState vars,
	Adaptive cursor,
	double x, double y, double z
	);

string FormatMoveXYZ_IJK(
	GenerateState vars,
	Adaptive cursor,
	double[3] xyz
	);

The FormatMoveXYZ() function returns a move command as if processing a MOVE event, but the given position is supplied by the caller rather than taken from a toolpath curve. The tool axis is not changed - use FormatMoveXYZ_IJK() to change the tool direction.

The position is given in program units and "vars" is updated. The position is used exactly as passed in, no destination transform is applied. The feed rate is not changed.

The function may return an empty string if no move is needed.

The coordinates can be provided as separate values or as an array.

FormatMoveXYZ_IJK()

System::String^ FormatMoveXYZ_IJK(			
	GenerateState^ vars,
	Adaptive^ cursor,
	double x, double y, double z,
	double i, double j, double k
	);


string FormatMoveXYZ_IJK(				
	GenerateState vars,
	Adaptive cursor,
	double x, double y, double z,
	double i, double j, double k
	);

string FormatMoveXYZ_IJK(
	GenerateState vars,
	Adaptive cursor,
	double[3] xyz,
	double[3] ijk
	);

The FormatMoveXYZ_IJK() function returns a move command as if processing a MOVE event, but the given position and tool axis direction is supplied by the caller rather than taken from a toolpath curve.

The position is given in program units and "vars" is updated. The position is used exactly as passed in, no destination transform is applied. The feed rate is not changed.

The function may return an empty string if no move is needed.

The coordinates and direction vectors can be provided as separate values or as a pair of arrays.

FormatOther()

System::String^ FormatOther(				
	GenerateState^ vars,
	Adaptive^ cursor,
	System::String^ name
	);


string FormatOther(					
	GenerateState vars,
	Adaptive cursor,
	string name
	);

The FormatOther() function keeps a dictionary of functions used by FormatEvent() to construct parts of the result text from the active state of the "cursor" and "vars" objects. The functions update "vars" as necessary and may advance the cursor. The function may return an empty string if no move is needed.

In our earlier example we called the "tool-comment" function. A partial list of available functions is shown below:

"coolant"
Turns flood, mist, or through-spindle coolant on or off as necessary based on the coolant state held by "vars" and the state of GetMoveIsCoolant(), GetMoveIsMistCoolant(), and GetMoveIsThruCoolant(). Calls "coolant-off" if needed to turn everything off. Called by the toolpath start event handling.
"coolant-off"
Turns off all coolant. Called by the tool change and program end event handling.
"filename"
Returns the name of the STEP-NC file as a comment. Usually called by the program start event handling.
"move-contact"
This is called by the MOVE event handling. If the cursor is currently traversing a cutter contact toolpath, this function examines the tool axis, movement direction, and surface normal direction. If it determines that the tool is contacting left or right, it will return the result of calling "refpoint-left" or "refpoint-right" respectively.
"move-feed"
This is called by the MOVE event handling. It examines the GetMoveFeed() and any speed override settings and if the feedrate has changed, it returns a new feed command. Depending on the value of GetFeedIsStandalone(), this is either returned on a separate line or appended to the end of the move command.
"move-ijk"
This is called by the MOVE event handling. It examines the tool axis direction returned by GetOutDirZ() and formats the tool axis portion of the movement command. This function may be set to versions that Format the direction as Fanic TCP IJK components, Siemens TRAORI A3/B3/C3 components, or AC/BC/AB angles for use with Okuma or Heidenhain TCP modes. It returns null if the tool axis has not changed from the last known direction held by "vars". The WCS tool axis is used, which has all setup and toolpath transforms applied. In addition the GetDstXform() transform is applied if required by GetUseXform().
"move-xyz"
This is called by the MOVE event handling. It examines the tool position returned by GetOutXYZ() and formats the position portion of the movement command. This function returns null if the tool axis has not changed from the last known direction held by "vars". The WCS position is used, which has all setup and toolpath transforms applied. In addition the GetDstXform() transform is applied if required by GetUseXform().
"ncfun-exchange-pallet"
This is called by the EXEC_NCFUN event handling for an "exchange pallet" NC function.
"ncfun-extended"
This is called by the EXEC_NCFUN event handling for an "extended nc-function" NC function.
"ncfun-index-pallet"
This is called by the EXEC_NCFUN event handling for an "index pallet" NC function.
"ncfun-index-table"
This is called by the EXEC_NCFUN event handling for an "index table" NC function.
"ncfun-message"
This is called by the EXEC_NCFUN event handling for a "message" NC function.
"ncfun-optional-stop"
This is called by the EXEC_NCFUN event handling for an "optional stop" NC function. It is also called durning the workingstep end event handling if required by GetStopAfterWorkingstep().
"ncfun-stop"
This is called by the EXEC_NCFUN event handling for an "stop" NC function.
"op-approach-paths"
This advances the cursor through the toolpaths in an operation until it finds a toolpath that is not marked as an "approach" path and "required". It returns all formatted MOVE events that it iterated over. This is used when processing an operation of type OP_PROBE to command the probe approach.
"op-lift-paths"
This advances the cursor through the toolpaths in an operation until it is finished or finds a toolpath that is not marked as an "lift" path and "required". It returns all formatted MOVE events that it iterated over. This is used when processing an operation of type OP_PROBE to command the probe departure after measurement.
"probe-comments"
This is used when processing an operation of type OP_PROBE. It returns a series of comments that describe the start, end, direction, and expected value of a probe.
"probe-datums"
This is only used during DMIS output to declare workpiece datums at the start of a program.
"refpoint-center"
This is called when processing the toolpath start event for a cutter loCation toolpath. By default, it adds a "G40" to the next move if previously in cutter contact mode. If needed, it registers the G40 as a prefix for the next move with vars.AddMovePrefix() and calls vars.SetRefpointCenter();
"refpoint-contact"
This is called when processing the toolpath start event for a cutter contact toolpath. By default, it and calls vars.SetRefpointContact()
"refpoint-left"
This is called by "move-contact" after it has determined where the cutter is in contact. If currently not vars.IsRefpointLeft(), the function calls vars.SetRefpointLeft() and returns "G41".
"refpoint-right"
This is called by "move-contact" after it has determined where the cutter is in contact. If currently not vars.IsRefpointRight(), the function calls vars.SetRefpointRight() and returns "G42".
"spindle"
Returns codes to turn the spindle on or off as necessary based on the value of GetMoveSpindle(). The spindle is Set to counter clockwise if the number is positive, clockwise if the number is negative, or "spindle-off" is called if the number is zero. Called by the toolpath start event handling.
"spindle-off"
Returns codes to turn off the spindle. Called by the tool change and program end event handling.
"tap-first"
This us called when processing an operation of type OP_TAP. It returns the starting portion of the tapping.
"tap-last"
This us called when processing an operation of type OP_TAP. It returns the concluding portion of the tapping.
"tap-point"
This us called when processing an operation of type OP_TAP. It is called with a GetPosEnd() position for each loCation that must be tapped.
"timestamp"
Returns the current time in ISO date format as a comment. Usually called by the program start event handling.
"tool-comment"
This is called by the tool change event handling to build a series of comments describing the parameters of the new tool.
"workoffset"
This is called by the project start event handling to declare the work offset frame requested by GetWorkOffsetFrame().
"workplan-probe-end"
This is called by the workplan start event handling to add additional commands at the beginning of workplans that contain OP_PROBE operations.
"workplan-probe-start"
This is called by the workplan end event handling to add additional commands at the completion of workplans that contain OP_PROBE operations.

FormatRapidXYZ()

System::String^ FormatRapidXYZ(				
	GenerateState^ vars,
	Adaptive^ cursor,
	double x, double y, double z
	);

string FormatRapidXYZ(					
	GenerateState vars,
	Adaptive cursor,
	double x, double y, double z
	);

string FormatRapidXYZ_IJK(
	GenerateState vars,
	Adaptive cursor,
	double[3] xyz
	);

The FormatRapidXYZ() function returns a move command as if processing a MOVE event at rapid feed, but the given position is supplied by the caller rather than taken from a toolpath curve. The tool axis is not changed - use FormatRapidXYZ_IJK() to change the tool direction.

The position is given in program units and "vars" is updated. The position is used exactly as passed in, no destination transform is applied. The feed rate will return to its previous value on the next move.

The function may return an empty string if no move is needed.

The coordinates can be provided as separate values or as an array.

FormatRapidXYZ_IJK()

System::String^ FormatRapidXYZ_IJK(			
	GenerateState^ vars,
	Adaptive^ cursor,
	double x, double y, double z,
	double i, double j, double k
	);


string FormatRapidXYZ_IJK(				
	GenerateState vars,
	Adaptive cursor,
	double x, double y, double z,
	double i, double j, double k
	);

string FormatRapidXYZ_IJK(
	GenerateState vars,
	Adaptive cursor,
	double[3] xyz,
	double[3] ijk
	);

The FormatRapidXYZ_IJK() function returns a move command as if processing a MOVE event at rapid feed, but the given position and tool axis direction is supplied by the caller rather than taken from a toolpath curve.

The position is given in program units and "vars" is updated. The position is used exactly as passed in, no destination transform is applied. The feed rate will return to its previous value on the next move.

The function may return an empty string if no move is needed.

The coordinates and direction vectors can be provided as separate values or as a pair of arrays.

FormatType()

System::String^ FormatType (				
	GenerateState^ vars,
	Adaptive^ cursor
	);


string FormatType (					
	GenerateState vars,
	Adaptive cursor
	);

The FormatType() function calls a formatting function based on the CtlType returned by the GetActiveType() of the process cursor. Typically this is done for MOVE and OPERATION_START events. The function may return an empty string if nothing is needed or no formatting function is registered for a particular type.

GetBlocknumLimit()

System::Int64 GetBlocknumLimit();			

int GetBlocknumLimit();					

The GetBlocknumLimit() function returns the upper limit of block numbers for a style, or zero if there is no limit. When numbering is turned on, the block numbers will wrap around if they reach the limit. The GenerateState GetLastBlocknum() function returns the last assigned number.

GetDigits()

System::Int64 GetDigits();				

int GetDigits();					

The GetDigits() function returns the maximum digits of precision used when formatting coordinate values. This is typically defined by the output format but may be changed to different values using the SetDigits() function depending on whether output is in inch, mm, etc. The GetMinDigits() function controls how many digits are always used and whether the trailing decimal point is left on integer values

GetDstXform()

array<double>^ GetDstXform()				

double[16] GetDstXform()				

The GetDstXform() function returns a pointer to a sixteen element array of doubles containing a destination transform for the output coordinates. This transform is only applied if GetUseXform() is true.

When outputting moves, the Adaptive will apply all setup and toolpath transforms to get the coordinates into the WCS. This destination transform is applied afterwards to modify the output for probing results or a machine-specific transform.

GetDstXformIsLeft()

System::Boolean GetDstXformIsLeft();			

bool GetDstXformIsLeft();				

The GetDstXformIsLeft() function returns true if the transform returned by GetDstXform() uses a left-handed coordinate system. Any transform derived from STEP data will, by definition, only use a right-handed coordinate system.

A left-handed transform, might be used by some machines, like a left-handed lathe. This will also reverse the direction of circular motion and spindle rotation.

GetFeedDigits()

System::Int64 GetFeedDigits();				

int GetFeedDigits();					

The GetFeedDigits() function returns the maximum digits of precision used when formatting feedrate values. This is typically defined by the output format but may be changed to different values using the SetFeedDigits() function. The GetFeedMinDigits() function controls how many digits are always used and whether the trailing decimal point is left on integer values.

GetFeedIsStandalone()

System::Boolean GetFeedIsStandalone();			

bool GetFeedIsStandalone();				

The GetFeedIsStandalone() function returns true if feedrate changes should be formatted on a separate line and false if they should be appended to the end of the move command to which they apply. Use SetFeedStandalone() and SetFeedInline() to change this value.

GetFeedMinDigits()

System::Int64 GetFeedMinDigits();			

int GetFeedMinDigits();					

The GetFeedMinDigits() function returns the minimum number of decimal digits that will be used for feedrate value. If this value is zero, integer values will have a trailing decimal point, if negative the decimal point will be stripped. See CatNumber() for examples.

GetFeedUnit()

RoseUnit GetFeedUnit()					 

The GetFeedUnit() function returns the velocity unit used for feed rate values.

This value will be set to inch/min or millimeter/min by SetUnitSystem() depending on whether GetLenUnit() is Set to inch or MM. The value may be also be changed with the SetLenUnit() function.

GetFileExt()

System::String^ GetFileExt();				

string GetFileExt();					

The GetFileExt() function returns the preferred filename extension for the configured Format. The values set by the pre-defined styles include the dot separator. For example, ".nc", ".min", etc. This value can be used by the caller to construct a filename.

GetLenUnit()

RoseUnit GetLenUnit()					 

The GetLenUnit() function returns the length unit used for all coordinate values and for the G70/G71-style units declaration that may appear at the start of a program.

This value is usually initialized from the GetProgramUnit() and process data by SetUnitSystem() but may be manually changed with the SetLenUnit() function.

If the program unit has a value of AS-IS roseunit_as_is, the length unit will be a more specific value of INCH/MM found by looking at the toolpath units used by the process. Otherwise the two values will be the same.

GetMinDigits()

System::Int64 GetMinDigits();				

int GetMinDigits();					

The GetMinDigits() function returns the minimum number of decimal digits that will be used for coordinate value. If this value is zero, integer values will have a trailing decimal point, if negative the decimal point will be stripped. See CatNumber() for examples.

GetOutArcAxis()

void GetOutArcAxis(					
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %i,
	[System::Runtime::InteropServices::Out] double %j,
	[System::Runtime::InteropServices::Out] double %k,
	Adaptive::CtlPos p
	);


double[3] GetOutArcAxis(				
	Adaptive cursor,
	CtlPos p
	);

The GetOutArcAxis() function is a convenience wrapper for Adaptive::GetArcAxis() that applies the destination transform to the value if needed.

The values are copied into the return parameters.

The values are returned as a three element array.

GetOutArcCenter()

void GetOutArcCenter(					
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %x,
	[System::Runtime::InteropServices::Out] double %y,
	[System::Runtime::InteropServices::Out] double %z,
	Adaptive::CtlPos p,
	RoseUnit u
	);

void GetOutArcCenter(
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %x,
	[System::Runtime::InteropServices::Out] double %y,
	[System::Runtime::InteropServices::Out] double %z,
	Adaptive::CtlPos p
	);


double[3] GetOutArcCenter(				
	Adaptive cursor,
	CtlPos p,
	RoseUnit u		(optional)
	);

The GetOutArcCenter() function is a convenience wrapper for Adaptive::GetArcCenter() that applies the destination transform to the value if needed. If a length unit is given, the coordinates will be converted to that unit.

The values are copied into the return parameters.

The values are returned as a three element array.

GetOutDirMove()

System::Boolean GetOutDirMove(				
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %i,
	[System::Runtime::InteropServices::Out] double %j,
	[System::Runtime::InteropServices::Out] double %k,
	Adaptive::CtlPos p
	);


double[3] GetOutDirMove(				
	Adaptive cursor,
	CtlPos p
	);

The GetOutDirMove() function is a convenience wrapper for Adaptive::GetPosDirMove() that applies the destination transform to the value if needed.

If the value is present, the function will return true and the values are copied into the return parameters.

If the value is present, it is returned as a three element array, otherwise the function returns undefined.

GetOutDirSnorm()

System::Boolean GetOutDirSnorm(				
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %i,
	[System::Runtime::InteropServices::Out] double %j,
	[System::Runtime::InteropServices::Out] double %k,
	Adaptive::CtlPos p
	);


double[3] GetOutDirSnorm(				
	Adaptive cursor,
	CtlPos p
	);

The GetOutDirSnorm() function is a convenience wrapper for Adaptive::GetPosDirSnorm() that applies the destination transform to the value if needed.

If the value is present, the function will return true and the values are copied into the return parameters.

If the value is present, it is returned as a three element array, otherwise the function returns undefined.

GetOutDirX()

void GetOutDirX(					
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %i,
	[System::Runtime::InteropServices::Out] double %j,
	[System::Runtime::InteropServices::Out] double %k,
	Adaptive::CtlPos p
	);


double[3] GetOutDirX(					
	Adaptive cursor,
	CtlPos p
	);

The GetOutDirX() function is a convenience wrapper for Adaptive::GetPosDirX() that calls GetPosDefaultDirX() if no tool reference direction is defined, and then applies the destination transform to the value if needed.

The values are copied into the return parameters.

The values are returned as a three element array.

GetOutDirZ()

void GetOutDirZ(					
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %i,
	[System::Runtime::InteropServices::Out] double %j,
	[System::Runtime::InteropServices::Out] double %k,
	Adaptive::CtlPos p
	);


double[3] GetOutDirZ(					
	Adaptive cursor,
	CtlPos p
	);

The GetOutDirZ() function is a convenience wrapper for Adaptive::GetPosDirZ() that calls GetPosDefaultDirZ() if no tool axis direction is defined, and then applies the destination transform to the value if needed.

The values are copied into the return parameters.

The values are returned as a three element array.

GetOutXYZ()

void GetOutXYZ(						
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %x,
	[System::Runtime::InteropServices::Out] double %y,
	[System::Runtime::InteropServices::Out] double %z,
	Adaptive::CtlPos p,
	RoseUnit u
	);

void GetOutXYZ(
	Adaptive^ cursor,
	[System::Runtime::InteropServices::Out] double %x,
	[System::Runtime::InteropServices::Out] double %y,
	[System::Runtime::InteropServices::Out] double %z,
	Adaptive::CtlPos p
	);


double[3] GetOutXYZ(					
	Adaptive cursor,
	CtlPos p,
	RoseUnit u		(optional)
	);

The GetOutXYZ() function is a convenience wrapper for Adaptive::GetPosXYZ() that applies the destination transform to the value if needed.

The values are copied into the return parameters.

The values are returned as a three element array.

GetOutXformedDir()

void GetOutXformedDir(					
	[System::Runtime::InteropServices::Out] double %ret_i,
	[System::Runtime::InteropServices::Out] double %ret_j,
	[System::Runtime::InteropServices::Out] double %ret_k,
	double in_i, double in_j, double in_k
	);


double[3] GetOutXformedDir(				
	double in_i, double in_j, double in_k
	);

double[3] GetOutXformedDir(
	double[3] in_ijk
	);

The GetOutXformedDir() function is a convenience wrapper that applies the destination transform to a direction vector if needed.

The direction vectors can be provided as separate values or as a pair of arrays.

GetOutXformedPoint()

void GetOutXformedPoint(				
	[System::Runtime::InteropServices::Out] double %ret_x,
	[System::Runtime::InteropServices::Out] double %ret_y,
	[System::Runtime::InteropServices::Out] double %ret_z,
	double in_x, double in_y, double in_z
	);


double[3] GetOutXformedPoint(				
	double in_x, double in_y, double in_z
	);

double[3] GetOutXformedPoint(
	double[3] in_xyz
	);

The GetOutXformedPoint() function is a convenience wrapper that applies the destination transform to a coordinate position if needed.

The coordinates can be provided as separate values or as a pair of arrays.

GetProgramNumber()

System::Int64 GetProgramNumber();			

int GetProgramNumber();					

The GetProgramNumber() function returns the preferred number that should be used for the program when generating Fanuc-like codes. Use SetProgramNumber() to change this value.

GetProgramUnit()

RoseUnit GetProgramUnit()				 

The GetProgramUnit() function returns the preferred unit system that should be used for generating output. Call SetProgramUnit() to change this.

The INCH value roseunit_in implies lengths in inches, feeds in inches per minute, and spindle speeds in RPM. The MILLIMETER value roseunit_mm implies lengths in mm, feeds in mm per minute, and spindle speeds in RPM.

Calling SetUnitSystem() before beginning to set the actual units for length, feed, and spindle based on your preference. If the program unit is AS-IS roseunit_as_is, this will search for the first toolpath units seen and set the unit system from that.

GetSpindleDigits()

System::Int64 GetSpindleDigits();			

int GetSpindleDigits();					

The GetSpindleDigits() function returns the maximum digits of precision used when formatting spindle speed values. This is typically defined by the output format but may be changed to different values using the SetSpindleDigits() function. The GetSpindleMinDigits() function controls how many digits are always used and whether the trailing decimal point is left on integer values.

GetSpindleMinDigits()

System::Int64 GetSpindleMinDigits();			

int GetSpindleMinDigits();				

The GetSpindleMinDigits() function returns the minimum number of decimal digits that will be used for spindle speed values. If this value is zero, integer values will have a trailing decimal point, if negative the decimal point will be stripped. See CatNumber() for examples.

GetSpindleUnit()

RoseUnit GetSpindleUnit()				 

The GetSpindleUnit() function returns the angular velocity unit used for spindle speed values.

This value will be set to revolution/min by SetUnitSystem(). The value may be also be changed with the SetSpindleUnit() function.

GetStopAfterWorkingstep()

System::Boolean GetStopAfterWorkingstep();		

bool GetStopAfterWorkingstep();				

The GetStopAfterWorkingstep() function returns true if the workingstep end event handling should insert an optional stop code into the output. Call SetStopAfterWorkingstep() to change this value.

GetSupressX/Y/Zpos()

System::Boolean GetSupressXpos();			
System::Boolean GetSupressYpos();
System::Boolean GetSupressZpos();

bool GetSupressXpos();					
bool GetSupressYpos();
bool GetSupressZpos();

The GetSupressX/Y/Zpos() functions return a flag for each axis. When true, the move formatting code supresses all mention of that axis. This can be used to suppress the Z axis, for example, for 2D output. It is used to suppress the Y axis for lathe output. You can change these values with the SetSupressX/Y/Zpos functions.

GetTraceComments()

TraceComments GetTraceComments();			

enum class TraceComments {
    none = 0,
    workplan = 1,	// before each workplan
    workingstep = 2,	// before each workingstep
    toolpath = 3,	// before each toolpath
    point = 4, 		// at each point.
    all = 5 		// all possible comments.
};

string GetTraceComments();				

The GetTraceComments() function returns an enum value that controls where descriptive comments are placed in the output. The levels go from less descriptive to more detailed, with one including the comments of the previous level. The default value is before each workingstep. Call SetTraceComments() to change this.

The Node version of this function uses string names for each commenting level rather than an enum. The recognized strings are "none", "all", "workplan", "workingstep", "toolpath", or "point".

GetUseBlocknums()

System::Boolean GetUseBlocknums();			

bool GetUseBlocknums();					

The GetUseBlocknums() function returns true if individual commands in the output should be preceedded by a "N" number. The FormatBlock function looks at this setting and prepends the number if needed.

This setting can be changed for most styles by SetUseBlocknums(). Some output styles, like "heidenhain", force this value to true because they require block numbers.

fmt.FormatBlock(vars,"HELLO WORLD");  // with GetUseBlocknums() false
=> HELLO WORLD

fmt.FormatBlock(vars,"HELLO WORLD");  // with GetUseBlocknums() true
=> N1234 HELLO WORLD

GetUseWhitespace()

System::Boolean GetUseWhitespace();			

bool GetUseWhitespace();				

The GetUseWhitespace() function returns true if parameters assembled by the CatParam() function should be separated by space characters. The CatSpace() also appends a space to non-empty inputs if this value is true. This setting can be changed by SetUseWhitespace().

RoseStringObject ret = "G1";
fmt.CatParam(ret, "X", 1.23);
fmt.CatParam(ret, "Y", 4.56);
fmt.CatParam(ret, "Z", 7.89);

=> G1X1.23Y4.56Z7.89		  // with GetUseWhitespace() false

=> G1 X1.23 Y4.56 Z7.89	  // with GetUseWhitespace() true

GetUseXform()

System::Boolean GetUseXform();				

bool GetUseXform();					

The GetUseXform() function returns true if the destination transform given by GetDstXform() should be applied to all coordinates and directions. This value can be changed by SetUseXform() and affects the behavior of all of the "GetOut" prefixed functions.

GetWorkOffsetFrame()

System::Int64 GetWorkOffsetFrame();			

int GetWorkOffsetFrame();				

The GetWorkOffsetFrame() function returns the preferred number of the work offset frame that should be selected by the project start event handling. The actual command may change from style to style, but typical usage is "G54" for frame #1, "G55" for frame #2, etc. This value can be changed by the SetWorkOffsetFrame() function.

IsFormattedIJK()

System::Boolean IsFormattedIJK(				
	double i1, double j1, double k1,
	double i2, double j2, double k2
	);


bool IsFormattedIJK(					
	double i1, double j1, double k1,
	double i2, double j2, double k2
	);

bool IsFormattedIJK(
	double[3] ijk1,
	double[3] ijk2,
	);

The IsFormattedIJK() function returns true if the two direction vectors are equal when formatted to the digits of precision given by the GetDigits() value.

The direction vectors can be provided as separate values or as a pair of arrays.

IsFormattedNumber()

System::Boolean IsFormattedNumber(			
	double num1,
	double num2
	);

System::Boolean IsFormattedNumber(
	double num1,
	double num2,
	System::Int64 max_digits
	);


bool IsFormattedNumber(					
	double num1,
	double num2,
	int max_digits		(optional)
	);

The IsFormattedNumber() function returns true if the two numbers equal when formatted to the digits of precision given by the GetDigits() value. A different Formatting specification can be passed in as an optional parameter.

IsFormattedXYZ()

System::Boolean IsFormattedXYZ(				
	double x1, double y1, double z1,
	double x2, double y2, double z2
	);


bool IsFormattedXYZ(					
	double x1, double y1, double z1,
	double x2, double y2, double z2
	);

bool IsFormattedXYZ(
	double[3] xyz1,
	double[3] xyz2
	);

The IsFormattedXYZ() function returns true if the two coordinates are equal when formatted to the digits of precision given by the GetDigits() value.

The coordinates can be provided as separate values or as a pair of arrays.

Reset()

void Reset();						 

The Reset() function restores the Generate object to default settings for all values, including user preferences like GetWorkOffsetFrame(), GetProgramUnits(), etc.

SetBlocknumLimit()

void SetBlocknumLimit (System::Int64 max);		

void SetBlocknumLimit (int d);				

The SetBlocknumLimit() function sets the upper limit of block numbers for a Format. Set to zero to indicate no limit. See GetBlocknumLimit() for more discussion on this use.

SetDigits()

void SetDigits (System::Int64 d);			

void SetDigits (int d);					

The SetDigits() function sets the maximum digits of precision used when Formatting coordinate values. See GetDigits() for more discussion.

SetDstXform()

void SetDstXform(					
	array<double>^ xf
	);

void SetDstXform(					
	double[16] xf
	);

The SetDstXform() function sets the destination transform for the output coordinates. The input must be a sixteen element array of doubles. See GetDstXform() for more discussion.

SetFeedDigits()

void SetFeedDigits (System::Int64 d);			

void SetFeedDigits (int d);				

The SetFeedDigits() function sets the maximum digits of precision used when formatting feedrate values. See GetFeedDigits() for discussion.

SetFeedInline()

void SetFeedInline();					 

The SetFeedInline() function sets the value returned by GetFeedIsStandalone() to false. This means that feedrate changes should be appended to the end of the move command to which they apply.

SetFeedMinDigits()

void SetFeedMinDigits (System::Int64 d);		

void SetFeedMinDigits (int d);				

The SetFeedMinDigits() function sets the minimum number of digits of precision used when formatting feedrate values. See GetFeedMinDigits() for discussion.

SetFeedStandalone()

void SetFeedStandalone();				 

The SetFeedStandalone() function sets the value returned by GetFeedIsStandalone() to true. This means that feedrate changes should be formatted on a separate line preceeding the move command to which they apply.

SetFeedUnit()

void SetFeedUnit (RoseUnit u);				 

The SetFeedUnit() function changes the linear velocity unit used for feed rate values. This value will be overwritten every time SetUnitSystem() is called. See GetFeedUnit() for more discussion.

SetFileExt()

void SetFileExt (System::String^ s);			

void SetFileExt (string s);				

The SetFileExt() function the preferred filename extension for the configured Format. See GetFileExt() for more discussion.

SetLenUnit()

void SetLenUnit (RoseUnit u);				 

The SetLenUnit() function changes the length unit used for all coordinate values. This value will be overwritten every time SetUnitSystem() is called. See GetLenUnit() for more discussion.

SetMinDigits()

void SetMinDigits (System::Int64 d);			

void SetMinDigits (int d);				

The SetMinDigits() function sets the minimum number of digits of precision used when formatting feedrate values. See GetMinDigits() for discussion.

SetProgramNumber()

void SetProgramNumber (System::Int64 d);		

void SetProgramNumber (int d);				

The SetProgramNumber() function sets the program number used for the program when generating Fanuc-like codes. See GetProgramNumber() for more discussion.

SetProgramUnit()

void SetProgramUnit (RoseUnit u);			 

The SetProgramUnit() function Sets the preferred unit system that should be used for generating output. See GetProgramUnit() for more discussion.

SetSpindleDigits()

void SetSpindleDigits (System::Int64 d);		

void SetSpindleDigits (int d);				

The SetSpindleDigits() function sets the maximum digits of precision used when formatting spindle speed values. See GetSpindleDigits() for discussion.

SetSpindleMinDigits()

void SetSpindleMinDigits (System::Int64 d);		

void SetSpindleMinDigits (int d);			

The SetSpindleMinDigits() function sets the minimum number of digits of precision used when formatting spindle speed values. See GetSpindleMinDigits() for discussion.

SetSpindleUnit()

void SetSpindleUnit (RoseUnit u);			 

The SetSpindleUnit() function changes the angular velocity unit used for spindle speed values. This value will be overwritten every time SetUnitSystem() is called. See GetSpindleUnit() for more discussion.

SetStopAfterWorkingstep()

void SetStopAfterWorkingstep (System::Boolean yn);	

void SetStopAfterWorkingstep (bool yn);			

The SetStopAfterWorkingstep() function sets a flag that controls whether the workingstep end event handling inserts an optional stop code into the output. See Call GetStopAfterWorkingstep() for more discussion.

SetStyle()

System::Boolean SetStyle (System::String^ name);	

bool SetStyle (string name);				

The SetStyle() function configures the Generate object to the built-in style with a given name. The function returns true if the style was found and false otherwise.

A full list of built-in style are documented in the lower-level STEP-NC Control Library.

Most styles begin by calling Reset() so any prior settings will be lost.

Adaptive ctl;
Generate fmt;
GenerateState vars;

ctl.StartProject();
ctl.SetWantedAll(true);

fmt.SetStyle("haas");
fmt.SetUnitSystem(ctl);

while (ctl.Next() != Adaptive.CtlEvent.DONE)
{
    Console.Write(fmt.FormatEvent(vars,ctl));
}


// generate again, but as okuma codes
ctl.StartProject();
fmt.SetStyle("okuma");  // Set desired style as Okuma
fmt.SetUnitSystem(ctl);
vars.Reset();		// clear vars

while (ctl.Next() != Adaptive.CtlEvent.DONE)
{
    Console.Write(fmt.FormatEvent(vars,ctl));
}

SetSupressX/Y/Zpos()

void SetSupressXpos (System::Boolean yn);		
void SetSupressYpos (System::Boolean yn);
void SetSupressZpos (System::Boolean yn);

void SetSupressXpos (bool yn);				
void SetSupressYpos (bool yn);
void SetSupressZpos (bool yn);

The SetSupressX/Y/Zpos() functions set a flag that supresses mention of particular axis. This may be useful for 2D output, lathes, etc. See GetSupressX/Y/Zpos for more details.

SetTraceComments()

void SetTraceComments (TraceComments t);		

void SetTraceComments (string t);			

The SetTraceComments() function sets an enum value that controls where descriptive comments are placed in the output. See GetTraceComments() for a description of the values and their effect.

The Node version of this function uses string names for each commenting level rather than an enum. The recognized strings are "none", "all", "workplan", "workingstep", "toolpath", or "point".

SetUnitSystem()

void SetUnitSystem (Adaptive^ ctl);			

void SetUnitSystem (Adaptive ctl);			

The SetUnitSystem() function sets the system of length, feed, and spindle speed units. These are set to match to match the program unit preference. If this is AS-IS, the function will use the supplied cursor to find the length units used by the toolpaths process, and set the unit system accordingly. The unit system values are returned by the GetLenUnit(), GetFeedUnit() and GetSpindleUnit() functions.

SetUseBlocknums()

void SetUseBlocknums (System::Boolean yn);		

void SetUseBlocknums (bool yn);				

The SetUseBlocknums() function sets a flag that indicates whether the FormatBlock function should prefix every line with a "N" number. See GetUseBlocknums() for more discussion.

SetUseWhitespace()

void SetUseWhitespace (System::Boolean yn);		

void SetUseWhitespace (bool yn);			

The SetUseWhitespace() function sets a flag that indicates whether numeric parameters should be separated by space characters in the output. See GetUseWhitespace() for more discussion and examples.

SetUseXform()

void SetUseXform (System::Boolean yn);			

void SetUseXform (bool yn);				

The SetUseXform() function sets a flag that indicates whether the destination transform given by GetDstXform() should be applied to all coordinates and directions. This affects the behavior of all of the "GetOut" prefixed functions. You can query this value with the GetUseXform() function.

SetWorkOffsetFrame()

void SetWorkOffsetFrame (System::Int64 d);		

void SetWorkOffsetFrame (int d);			

The SetWorkOffsetFrame() function sets the preferred number of the work offset frame that should be selected by the project start event handling. A value of -1 means "as-is", do not change any offset settings. See GetWorkOffsetFrame() for more discussion.