Overview

The GenerateState class holds state information when making machine tool codes with the Generate class. It holds the last commanded positions, feed, speed, and so forth. The generator uses these values to avoid issuing duplicate moves to the same coordinates.

add_move_comment()

def add_move_comment(self, code: str) -> None:

The add_move_comment() function appends an already-formatted comment to a string variable. These comments are returned by the get_move_comment() function and prepended to the results of the next formatted MOVE event. The clear_move_comment() function empties the string.

add_move_prefix()

def add_move_prefix(self, code: str) -> None:

The add_move_prefix() function appends a string to the cached values that will be prepended to the next move command. Some commands must be issued with a move, so this lets you schedule codes to be emitted later when a move is done. For example, a tool change event processing may add a "G43 H..." prefix to set tool offsets, which typically must be issued with the next G1 or G0 command. The clear_move_prefix() function empties the string.

clear_coolant()

def clear_coolant(self) -> None:

The clear_coolant() function clears the stored coolant state information which is used to avoid redundant coolant commands.

clear_feed()

def clear_feed(self) -> None:

The clear_feed() function clears the stored feedrate state information which is used to avoid repeated feed commands.

clear_move_comment()

def clear_move_comment(self) -> None:

The clear_move_prefix() function any comment string intended to be issued before the next move command.

clear_move_mode()

def clear_move_mode(self) -> None:

The clear_move_mode() function clears the stored move mode (G0/G1/G2/G3/etc) information which is used to avoid repeated mode commands.

clear_move_prefix()

def clear_move_prefix(self) -> None:

The clear_move_prefix() function any prefix string intended to be prepended to the next move command.

clear_position()

def clear_position(self) -> None:

The clear_position() function clears stored position information which is used to avoid redundant commands to move an axis when the machine tool is already at that location.

clear_program_stats()

def clear_program_stats(self) -> None:

The clear_program_stats() function any program statistics computed by set_program_stats()

clear_refpoint()

def clear_refpoint(self) -> None:

The clear_refpoint() function clears stored reference point (center/contact) state.

clear_spindle()

def clear_spindle(self) -> None:

The clear_spindle() function clears the stored spindle speed state information which is used to avoid repeated spindle commands.

get_a/b/cpos()

def get_apos(self) -> float:
def get_bpos(self) -> float:
def get_cpos(self) -> float:

The get_a/b/cpos() functions return the last commanded value for the rotational axes. These are only set if the output style explicitly commands these axes. Some output styles tilt the tool by commanding an I/J/K direction vector, in which case these A/B/C values would remain null. These can be changed by the set_a/b/cpos() functions.

'''Get last commanded state of flood coolant.''' '''Get last commanded state of mist coolant.''' '''Get last commanded state of thru tool coolant.''' '''Set last commanded state of flood coolant.''' '''Set last commanded state of mist coolant.''' '''Set last commanded state of thru tool coolant.'''

get_coolant()

def get_coolant(self) -> bool:

The get_coolant() function returns true if the last commanded state of flood coolant was on. The set_coolant() function changes this value.

get_coolant_mist()

def get_coolant_mist(self) -> bool:

The get_coolant_mist() function returns true if the last commanded state of mist coolant was on. The set_coolant_mist() function changes this value.

get_coolant_thru()

def get_coolant_thru(self) -> bool:

The get_coolant_thru() function returns true if the last commanded state of thru spindle coolant was on. The set_coolant_thru() function changes this value.

get_feed()

def get_feed(self) -> float:

The get_feed() functions returns the last commanded numeric feedrate. The set_feed() function changes this value. This is not affected by rapid moves, but the get_move_mode() function can be used to test whether the last commanded move was rapid motion.

get_i/j/kpos()

def get_ipos(self) -> float:
def get_jpos(self) -> float:
def get_kpos(self) -> float:

def get_ijkpos(self) -> tuple[float, float, float]:

The get_i/y/zpos() functions return the last commanded I, J, K tool axis values. The values may be None if the axis has not yet been commanded. This is always set when the tool axis changes, even if the output styles commands the A/B/C axes. There are functions for each individual direction component and a group function that returns all of the components as a direction object. These can be changed by the set_i/j/kpos() functions.

get_last_blocknum()

def get_last_blocknum(self) -> int:

The get_last_blocknum() function returns the last assigned block number. To increment or change the count, use get_next_blocknum() or set_blocknum()

get_move_comment()

def get_move_comment(self) -> str:

The get_move_comment() function returns a string containing already-formatted comments that should be prepended to the results of the next formatted MOVE event. This is typically used for trace comments. See add_move_comment() for more discussion.

get_move_mode()

def get_move_mode(self) -> int:

The get_move_mode() function returns a numeric value for the last commanded modal move state. There are many modal states on CNC controls, but this value is used to avoid duplicating G0/G1 codes when issuing a series of moves. This value is -1 when unknown, zero when in "G0" rapid motion, one in "G1" motion, 2 in "G2" circular interpolation, etc. The set_move_mode() function changes this value.

get_move_prefix()

def get_move_prefix(self) -> str:

The get_move_prefix() function returns the current value of the string that should be prepended to the next move command. Values can be appended to this string with add_move_prefix()

get_next_blocknum()

def get_next_blocknum(self) -> int:

The get_next_blocknum() function increments the block number counter and returns the new value. The GetLastBlocknum() function returns the value without incrementing it and SetBlocknum() assigns a new value.

get_next_probe_index()

def get_next_probe_index(self) -> int:

The get_next_probe_index() function increments the number of probing operations visited so far and returns the new value. The get_probe_index() function returns the value without incrementing and set_probe_index() assigns a new value.

get_probe_count()

def get_probe_count(self) -> int:

The get_probe_count() function returns the number of probing operations found in the program. This does not count any disabled operations that would not be visited by the cursor. This value is computed by the set_program_stats() function.

get_probe_index()

def get_probe_index(self) -> int:

The get_probe_index() function returns the number of probing operations visited so far. It is incremented by the get_next_probe_index() function and can be given a new value by the set_probe_index() function.

get_program_has_5axis()

def get_program_has_5axis(self) -> bool:

The get_program_has_5axis() function returns true if any of the toolpaths in the program include a tool axis curve. This does not count any disabled operations that would not be visited by the cursor. This value is computed by the set_program_stats() function.

get_program_has_probes()

def get_program_has_probes(self) -> bool:

The get_program_has_probes() function returns true if the program includes any probing operations. This does not count any disabled operations that would not be visited by the cursor. This value is computed by the set_program_stats() function. This is equivalent to testing whether get_probe_count() is greater than zero.

get_spindle()

def get_spindle(self) -> float:

The get_spindle() functions returns the last commanded numeric spindle speed. The value is zero if the spindle was off, positive if the direction was counter clockwise, or negative if it is clockwise. The set_spindle() function changes this value.

get_x/y/zpos()

def get_xpos(self) -> float:
def get_ypos(self) -> float:
def get_zpos(self) -> float:

def get_xyzpos(self) -> tuple[float, float, float]:

The get_x/y/zpos() functions return the last commanded X, Y, Z axis values. The values may be None if the position has not yet been commanded. There are functions for each individual axis and a group function that returns all of the components as a point object. These can be changed by the set_x/y/zpos() functions.

is_changed_ijkpos()

def is_changed_ijkpos(self,
	i:float,
	j:float,
	k:float
	) -> bool:

The is_changed_ijkpos() function compares the input direction with the last commanded tool axis direction and returns true if any of the components have changed. This does an epsilon comparison that is usually stricter than the is_formatted_ijk() comparison of the Generate class.

is_changed_ijkpos_3axis()

def is_changed_ijkpos_3axis(self,
	i:float,
	j:float,
	k:float
	) -> bool:

The is_changed_ijkpos_3axis() function returns true if any of the direction components have changed, but assumes that if the program does not have any 5-axis moves and the last commanded values are null, that they are equivalent to (0,0,1). As with is_changed_ijkpos(), this does an epsilon comparison of the values rather than the formatted comparison.

is_changed_xyzpos()

def is_changed_xyzpos(self,
	x:float,
	y:float,
	z:float
	) -> bool:

The is_changed_xyzpos() function compares the X, Y, Z values with last commanded axis values and returns true if any of them are different. This does an epsilon comparison of the values that is usually stricter than the is_formatted_xyz() comparison of the Generate class.

is_refpoint_center()

def is_refpoint_center(self) -> bool:

The is_refpoint_center() function returns true if move commands are in reference to the tool center point. This is the default.

is_refpoint_contact()

def is_refpoint_contact(self) -> bool:

The is_refpoint_contact() function returns true if move commands are in reference to the tool contact point. STEP-NC process data can provide a range of surface normals for cutter contact paths, but traditionally machines are only able to handle contact on the left or right side of the tool. Change this value by calling set_refpoint_center() or set_refpoint_contact().

is_refpoint_left()

def is_refpoint_left(self) -> bool:

The is_refpoint_left() function returns true if in contact mode and set_refpoint_left() has been called.

is_refpoint_right()

def is_refpoint_right(self) -> bool:

The is_refpoint_right() function returns true if in contact mode and set_refpoint_right() has been called.

is_unknown_ijkpos()

def is_unknown_ijkpos(self) -> bool:

The is_unknown_ijkpos() function returns true if all of the components of the last commanded tool axis direction are None.

is_unknown_xyzpos()

def is_unknown_xyzpos(self) -> bool:

The is_unknown_xyzpos() function returns true if all of the components of the last commanded tool position are None.

reset()

def reset(self) -> None:

The reset() function clears all variables and returns them to the default state.

set_a/b/cpos()

def set_apos(self, a:float) -> None:
def set_bpos(self, b:float) -> None:
def set_cpos(self, c:float) -> None:

The set_a/b/cpos() functions set the last commanded value for the rotational axes. See get_a/b/cpos() for more discussion.

set_blocknum()

def set_blocknum(self,
	num: int
	) -> None:

The set_blocknum() function sets the current number used when prepending a "N" prefix to lines. See get_last_blocknum() for more discussion.

set_coolant()

def set_coolant(self, val:bool) -> None:

The set_coolant() function sets the last commanded on/off state for flood coolant to the given value.

set_coolant_mist()

def set_coolant_mist(self, val:bool) -> None:

The set_coolant_mist() function sets the last commanded on/off state for mist coolant to the given value.

set_coolant_thru()

def set_coolant_thru(self, val:bool) -> None:

The set_coolant_thru() function sets the last commanded on/off state for thru spindle coolant to the given value.

set_feed()

def set_feed(self, val:float) -> None:

The set_feed() function sets the last commanded feedrate to the given value. See get_feed() for more discussion.

set_i/j/kpos()

def set_ipos(self, i:float) -> None:
def set_jpos(self, j:float) -> None:
def set_kpos(self, k:float) -> None:

def set_ijkpos(self, i:float, j:float, k:float) -> None:

The set_i/j/kpos() functions set the last commanded IJK tool axis values.

set_move_mode()

def set_move_mode(self, val:int) -> None:

The set_move_mode() function sets a numeric value for the last commanded modal move state - zero for G0, one for G1, etc. This value is used to avoid duplicating G0/G1 codes when issuing a series of moves.

set_probe_count()

def set_probe_count(self, val:int) -> None:

The set_probe_count() function sets the count of probing operations found in the program. Normally, this value is computed and set by the set_program_stats() function. See get_probe_count() for more discussion.

set_probe_index()

def set_probe_index(self, val:int) -> None:

The set_probe_index() function sets the number of probing operations visited so far. It can be incremented by the get_next_probe_index() function. See get_probe_index() for more discussion.

set_program_has_5axis()

def set_program_has_5axis(self, val:bool) -> None:

The set_program_has_5axis() function sets a flag indicating whether any five axis moves are found in the program. Normally, this value is computed and set by the set_program_stats() function. See get_program_has_5axis() for more discussion.

set_program_stats()

def set_program_stats(self,
	cursor: Adaptive
	) -> None:

The set_program_stats() function scans the program being traversed by an Adaptive object and gathers statistics useful for planning code generation such as whether the program contains probes or five axis motion. The position of the Adaptive object is not changed.

set_refpoint_center()

def set_refpoint_center(self) -> None:

The set_refpoint_center() function sets the is_refpoint_center() flag to true and is_refpoint_contact() to false, indicating that commands are in reference to the tool center point.

set_refpoint_contact()

def set_refpoint_contact(self) -> None:

The set_refpoint_contact() function sets the is_refpoint_center() flag to false and is_refpoint_contact() to true, indicating that commands are in reference to the cutter contact point. A call to this function is expected to be followed by a call to set_refpoint_left() or set_refpoint_right().

set_refpoint_left()

def set_refpoint_left(self) -> None:

The set_refpoint_left() function sets the is_refpoint_left() flag to true and is_refpoint_right() to false.

set_refpoint_right()

def set_refpoint_right(self) -> None:

The set_refpoint_right() function sets the is_refpoint_left() flag to false and is_refpoint_right() to true.

set_spindle()

def set_spindle(self, val:float) -> None:

The set_spindle() function sets the last commanded spindle speed to the given value. The value is zero if the spindle was off, positive if the direction was counter clockwise, or negative if it is clockwise. See get_spindle() for more discussion.

set_x/y/zpos()

def set_xpos(self, x:float) -> None:
def set_ypos(self, y:float) -> None:
def set_zpos(self, z:float) -> None:

def set_xyzpos(self, x:float, y:float, z:float) -> None:

The set_x/y/zpos() functions set the last commanded X, Y, Z axis values.