########################## TCL Event Handlers ##########################

b.tcl - 3_axis_mill

这是 3 轴铣床。

Created by dp @ Wednesday, November 06, 2019 8:52:33 AM China Standard Time

with Post Builder version 10.0.3.

########################################################################

#=============================================================
proc PB_CMD___log_revisions { } {
#=============================================================

Dummy command to log changes in this post –

15-Jul-2014 gsl - Initial version

}

set cam_post_dir [MOM_ask_env_var UGII_CAM_POST_DIR]
set this_post_dir “[file dirname [info script]]”

if { ![info exists mom_sys_post_initialized] } {

 if { ![info exists mom_sys_ugpost_base_initialized] } {source ${cam_post_dir}ugpost_base.tclset mom_sys_ugpost_base_initialized 1}set mom_sys_debug_mode OFFif { ![info exists env(PB_SUPPRESS_UGPOST_DEBUG)] } {set env(PB_SUPPRESS_UGPOST_DEBUG) 0}if { $env(PB_SUPPRESS_UGPOST_DEBUG) } {set mom_sys_debug_mode OFF}if { ![string compare $mom_sys_debug_mode "OFF"] } {proc MOM_before_each_add_var {} {}proc MOM_before_each_event   {} {}proc MOM_before_load_address {} {}proc MOM_end_debug {} {}} else {set cam_debug_dir [MOM_ask_env_var UGII_CAM_DEBUG_DIR]source ${cam_debug_dir}mom_review.tcl}MOM_set_debug_mode $mom_sys_debug_mode

Listing File variables

 set mom_sys_list_output                       "OFF"set mom_sys_header_output                     "OFF"set mom_sys_list_file_rows                    "40"set mom_sys_list_file_columns                 "30"set mom_sys_warning_output                    "OFF"set mom_sys_warning_output_option             "FILE"set mom_sys_group_output                      "OFF"set mom_sys_list_file_suffix                  "lpt"set mom_sys_output_file_suffix                "ptp"set mom_sys_commentary_output                 "ON"set mom_sys_commentary_list                   "x y z 4axis 5axis feed speed"set mom_sys_pb_link_var_mode                  "OFF"

#=============================================================
proc MOM_before_output { } {
#=============================================================

This command is executed just before every NC block is

to be output to a file.

- Never overload this command!

- Any customization should be done in PB_CMD_before_output!

  if { [llength [info commands PB_CMD_kin_before_output]] &&\[llength [info commands PB_CMD_before_output]] } {PB_CMD_kin_before_output}

######### The following procedure invokes the listing file with warnings.

  global mom_sys_list_outputif { [string match "ON" $mom_sys_list_output] } {LIST_FILE} else {global tape_bytes mom_o_bufferif { ![info exists tape_bytes] } {set tape_bytes [string length $mom_o_buffer]} else {incr tape_bytes [string length $mom_o_buffer]}}

}

 if { [string match "OFF" [MOM_ask_env_var UGII_CAM_POST_LINK_VAR_MODE]] } {set mom_sys_link_var_mode                     "OFF"} else {set mom_sys_link_var_mode                     "$mom_sys_pb_link_var_mode"}set mom_sys_control_out                       "("set mom_sys_control_in                        ")"# Retain UDE handlers of ugpost_baseforeach ude_handler { MOM_insert \MOM_operator_message \MOM_opskip_off \MOM_opskip_on \MOM_pprint \MOM_text \} \{if { [llength [info commands $ude_handler]] &&\![llength [info commands ugpost_${ude_handler}]] } {rename $ude_handler ugpost_${ude_handler}}}set mom_sys_post_initialized 1

}

set mom_sys_use_default_unit_fragment “ON”
set mom_sys_alt_unit_post_name “b__IN.pui”

########## SYSTEM VARIABLE DECLARATIONS ##############
set mom_sys_rapid_code “0”
set mom_sys_linear_code “1”
set mom_sys_circle_code(CLW) “2”
set mom_sys_circle_code(CCLW) “3”
set mom_sys_delay_code(SECONDS) “4”
set mom_sys_delay_code(REVOLUTIONS) “4”
set mom_sys_cutcom_plane_code(XY) “17”
set mom_sys_cutcom_plane_code(ZX) “18”
set mom_sys_cutcom_plane_code(XZ) “18”
set mom_sys_cutcom_plane_code(YZ) “19”
set mom_sys_cutcom_plane_code(ZY) “19”
set mom_sys_cutcom_code(OFF) “40”
set mom_sys_cutcom_code(LEFT) “41”
set mom_sys_cutcom_code(RIGHT) “42”
set mom_sys_adjust_code “43”
set mom_sys_adjust_code_minus “44”
set mom_sys_adjust_cancel_code “49”
set mom_sys_unit_code(IN) “70”
set mom_sys_unit_code(MM) “71”
set mom_sys_cycle_start_code “79”
set mom_sys_cycle_off “80”
set mom_sys_cycle_drill_code “81”
set mom_sys_cycle_drill_dwell_code “82”
set mom_sys_cycle_drill_deep_code “83”
set mom_sys_cycle_drill_break_chip_code “73”
set mom_sys_cycle_tap_code “84”
set mom_sys_cycle_bore_code “85”
set mom_sys_cycle_bore_drag_code “86”
set mom_sys_cycle_bore_no_drag_code “76”
set mom_sys_cycle_bore_dwell_code “89”
set mom_sys_cycle_bore_manual_code “88”
set mom_sys_cycle_bore_back_code “87”
set mom_sys_cycle_bore_manual_dwell_code “88”
set mom_sys_output_code(ABSOLUTE) “90”
set mom_sys_output_code(INCREMENTAL) “91”
set mom_sys_cycle_ret_code(AUTO) “98”
set mom_sys_cycle_ret_code(MANUAL) “99”
set mom_sys_reset_code “92”
set mom_sys_spindle_mode_code(SFM) “96”
set mom_sys_spindle_mode_code(RPM) “97”
set mom_sys_return_code “28”
set mom_sys_feed_rate_mode_code(FRN) “93”
set mom_sys_feed_rate_mode_code(MMPM) “94”
set mom_sys_feed_rate_mode_code(MMPR) “95”
set mom_sys_program_stop_code “0”
set mom_sys_optional_stop_code “1”
set mom_sys_end_of_program_code “2”
set mom_sys_spindle_direction_code(CLW) “3”
set mom_sys_spindle_direction_code(CCLW) “4”
set mom_sys_spindle_direction_code(OFF) “5”
set mom_sys_tool_change_code “6”
set mom_sys_coolant_code(ON) “8”
set mom_sys_coolant_code(FLOOD) “8”
set mom_sys_coolant_code(MIST) “7”
set mom_sys_coolant_code(THRU) “26”
set mom_sys_coolant_code(TAP) “27”
set mom_sys_coolant_code(OFF) “9”
set mom_sys_rewind_code “30”
set mom_sys_4th_axis_has_limits “1”
set mom_sys_5th_axis_has_limits “1”
set mom_sys_sim_cycle_drill “0”
set mom_sys_sim_cycle_drill_dwell “0”
set mom_sys_sim_cycle_drill_deep “0”
set mom_sys_sim_cycle_drill_break_chip “0”
set mom_sys_sim_cycle_tap “0”
set mom_sys_sim_cycle_bore “0”
set mom_sys_sim_cycle_bore_drag “0”
set mom_sys_sim_cycle_bore_nodrag “0”
set mom_sys_sim_cycle_bore_manual “0”
set mom_sys_sim_cycle_bore_dwell “0”
set mom_sys_sim_cycle_bore_manual_dwell “0”
set mom_sys_sim_cycle_bore_back “0”
set mom_sys_cir_vector “Vector - Arc Start to Center”
set mom_sys_spindle_ranges “0”
set mom_sys_rewind_stop_code “#”
set mom_sys_home_pos(0) “0”
set mom_sys_home_pos(1) “0”
set mom_sys_home_pos(2) “0”
set mom_sys_zero “0”
set mom_sys_opskip_block_leader “/”
set mom_sys_seqnum_start “10”
set mom_sys_seqnum_incr “10”
set mom_sys_seqnum_freq “1”
set mom_sys_seqnum_max “9999”
set mom_sys_lathe_x_double “1”
set mom_sys_lathe_i_double “1”
set mom_sys_lathe_y_double “1”
set mom_sys_lathe_j_double “1”
set mom_sys_lathe_x_factor “1”
set mom_sys_lathe_y_factor “1”
set mom_sys_lathe_z_factor “1”
set mom_sys_lathe_i_factor “1”
set mom_sys_lathe_j_factor “1”
set mom_sys_lathe_k_factor “1”
set mom_sys_leader(N) “N”
set mom_sys_leader(X) “X”
set mom_sys_leader(Y) “Y”
set mom_sys_leader(Z) “Z”
set mom_sys_leader(fourth_axis) “B”
set mom_sys_leader(fifth_axis) “B”
set mom_sys_contour_feed_mode(LINEAR) “MMPM”
set mom_sys_rapid_feed_mode(LINEAR) “MMPM”
set mom_sys_cycle_feed_mode “MMPM”
set mom_sys_feed_param(IPM,format) “Feed_IPM”
set mom_sys_feed_param(IPR,format) “Feed_IPR”
set mom_sys_feed_param(FRN,format) “Feed_INV”
set mom_sys_vnc_rapid_dogleg “1”
set mom_sys_prev_mach_head “”
set mom_sys_curr_mach_head “”
set mom_sys_feed_param(MMPM,format) “Feed_MMPM”
set mom_sys_feed_param(MMPR,format) “Feed_MMPR”
set mom_sys_tool_number_max “32”
set mom_sys_tool_number_min “1”
set mom_sys_post_description “这是 3 轴铣床。”
set mom_sys_ugpadvkins_used “0”
set mom_sys_post_builder_version “10.0.3”

####### KINEMATIC VARIABLE DECLARATIONS ##############
set mom_kin_4th_axis_ang_offset “0.0”
set mom_kin_4th_axis_center_offset(0) “0.0”
set mom_kin_4th_axis_center_offset(1) “0.0”
set mom_kin_4th_axis_center_offset(2) “0.0”
set mom_kin_4th_axis_direction “MAGNITUDE_DETERMINES_DIRECTION”
set mom_kin_4th_axis_incr_switch “OFF”
set mom_kin_4th_axis_leader “B”
set mom_kin_4th_axis_limit_action “Warning”
set mom_kin_4th_axis_max_limit “360”
set mom_kin_4th_axis_min_incr “0.001”
set mom_kin_4th_axis_min_limit “0”
set mom_kin_4th_axis_plane “ZX”
set mom_kin_4th_axis_point(0) “0.0”
set mom_kin_4th_axis_point(1) “0.0”
set mom_kin_4th_axis_point(2) “0.0”
set mom_kin_4th_axis_rotation “standard”
set mom_kin_4th_axis_type “Table”
set mom_kin_4th_axis_vector(0) “0.0”
set mom_kin_4th_axis_vector(1) “1.0”
set mom_kin_4th_axis_vector(2) “0.0”
set mom_kin_4th_axis_zero “0.0”
set mom_kin_5th_axis_center_offset(0) “0.0”
set mom_kin_5th_axis_center_offset(1) “0.0”
set mom_kin_5th_axis_center_offset(2) “0.0”
set mom_kin_5th_axis_incr_switch “OFF”
set mom_kin_5th_axis_max_limit “0.0”
set mom_kin_5th_axis_min_incr “0.0”
set mom_kin_5th_axis_min_limit “0.0”
set mom_kin_5th_axis_point(0) “0.0”
set mom_kin_5th_axis_point(1) “0.0”
set mom_kin_5th_axis_point(2) “0.0”
set mom_kin_5th_axis_vector(0) “0.0”
set mom_kin_5th_axis_vector(1) “1.0”
set mom_kin_5th_axis_vector(2) “0.0”
set mom_kin_5th_axis_zero “0.0”
set mom_kin_arc_output_mode “FULL_CIRCLE”
set mom_kin_arc_valid_plane “XYZ”
set mom_kin_clamp_time “2.0”
set mom_kin_cycle_plane_change_per_axis “0”
set mom_kin_cycle_plane_change_to_lower “0”
set mom_kin_flush_time “2.0”
set mom_kin_linearization_flag “1”
set mom_kin_linearization_tol “0.01”
set mom_kin_machine_resolution “.001”
set mom_kin_machine_type “3_axis_mill”
set mom_kin_machine_zero_offset(0) “0.0”
set mom_kin_machine_zero_offset(1) “0.0”
set mom_kin_machine_zero_offset(2) “0.0”
set mom_kin_max_arc_radius “99999.999”
set mom_kin_max_dpm “10”
set mom_kin_max_fpm “10000”
set mom_kin_max_fpr “100”
set mom_kin_max_frn “100”
set mom_kin_min_arc_length “0.20”
set mom_kin_min_arc_radius “0.001”
set mom_kin_min_dpm “0.0”
set mom_kin_min_fpm “0.01”
set mom_kin_min_fpr “0.01”
set mom_kin_min_frn “0.01”
set mom_kin_output_unit “MM”
set mom_kin_pivot_gauge_offset “0.0”
set mom_kin_pivot_guage_offset “”
set mom_kin_post_data_unit “MM”
set mom_kin_rapid_feed_rate “15000”
set mom_kin_rotary_axis_method “PREVIOUS”
set mom_kin_spindle_axis(0) “0.0”
set mom_kin_spindle_axis(1) “0.0”
set mom_kin_spindle_axis(2) “1.0”
set mom_kin_tool_change_time “12.0”
set mom_kin_x_axis_limit “1000”
set mom_kin_y_axis_limit “1000”
set mom_kin_z_axis_limit “1000”

if [llength [info commands MOM_SYS_do_template] ] {
if [llength [info commands MOM_do_template] ] {
rename MOM_do_template “”
}
rename MOM_SYS_do_template MOM_do_template
}

#=============================================================
proc MOM_start_of_program { } {
#=============================================================
global mom_logname mom_date is_from
global mom_coolant_status mom_cutcom_status
global mom_clamp_status mom_cycle_status
global mom_spindle_status mom_cutcom_plane pb_start_of_program_flag
global mom_cutcom_adjust_register mom_tool_adjust_register
global mom_tool_length_adjust_register mom_length_comp_register
global mom_flush_register mom_wire_cutcom_adjust_register
global mom_wire_cutcom_status

set pb_start_of_program_flag 0
set mom_coolant_status UNDEFINED
set mom_cutcom_status  UNDEFINED
set mom_clamp_status   UNDEFINED
set mom_cycle_status   UNDEFINED
set mom_spindle_status UNDEFINED
set mom_cutcom_plane   UNDEFINED
set mom_wire_cutcom_status  UNDEFINEDcatch {unset mom_cutcom_adjust_register}
catch {unset mom_tool_adjust_register}
catch {unset mom_tool_length_adjust_register}
catch {unset mom_length_comp_register}
catch {unset mom_flush_register}
catch {unset mom_wire_cutcom_adjust_register}set is_from ""catch { OPEN_files } ;# Open warning and listing files
LIST_FILE_HEADER     ;# List header in commentary listing

global mom_sys_post_initialized
if { $mom_sys_post_initialized > 1 } { return }

Load parameters for alternate output units

PB_load_alternate_unit_settings
rename PB_load_alternate_unit_settings ""

#************
uplevel #0 {

#=============================================================
proc MOM_sync { } {
#=============================================================
if [llength [info commands PB_CMD_kin_handle_sync_event] ] {
PB_CMD_kin_handle_sync_event
}
}

#=============================================================
proc MOM_set_csys { } {
#=============================================================
if [llength [info commands PB_CMD_kin_set_csys] ] {
PB_CMD_kin_set_csys
}
}

#=============================================================
proc MOM_msys { } {
#=============================================================
}

#=============================================================
proc MOM_end_of_program { } {
#=============================================================
MOM_do_template end_of_program
MOM_set_seq_off
MOM_do_template rewind_stop_code

#**** The following procedure lists the tool list with time in commentary data
LIST_FILE_TRAILER

#**** The following procedure closes the warning and listing files
CLOSE_files

if [llength [info commands PB_CMD_kin_end_of_program] ] {
PB_CMD_kin_end_of_program
}
}

incr mom_sys_post_initialized

} ;# uplevel
#***********

}

#=============================================================
proc PB_init_new_iks { } {
#=============================================================
global mom_kin_iks_usage mom_kin_spindle_axis
global mom_kin_4th_axis_vector mom_kin_5th_axis_vector

set mom_kin_iks_usage 1

Override spindle axis vector defined in PB_CMD_init_rotary

set mom_kin_spindle_axis(0) 0.0
set mom_kin_spindle_axis(1) 0.0
set mom_kin_spindle_axis(2) 1.0

Unitize vectors

foreach i { 0 1 2 } {
set vec($i) m o m k i n s p i n d l e a x i s ( mom_kin_spindle_axis( momk​ins​pindlea​xis(i)
}
VEC3_unitize vec mom_kin_spindle_axis

foreach i { 0 1 2 } {
set vec($i) m o m k i n 4 t h a x i s v e c t o r ( mom_kin_4th_axis_vector( momk​in4​tha​xisv​ector(i)
}
VEC3_unitize vec mom_kin_4th_axis_vector

foreach i { 0 1 2 } {
set vec($i) m o m k i n 5 t h a x i s v e c t o r ( mom_kin_5th_axis_vector( momk​in5​tha​xisv​ector(i)
}
VEC3_unitize vec mom_kin_5th_axis_vector

Reload kinematics

MOM_reload_kinematics
}

#=============================================================
proc PB_DELAY_TIME_SET { } {
#=============================================================
global mom_sys_delay_param mom_delay_value
global mom_delay_revs mom_delay_mode delay_time

Post Builder provided format for the current mode:

if { [info exists mom_sys_delay_param(${mom_delay_mode},format)] != 0 } {
MOM_set_address_format dwell m o m s y s d e l a y p a r a m ( mom_sys_delay_param( moms​ysd​elayp​aram({mom_delay_mode},format)
}

switch $mom_delay_mode {
SECONDS { set delay_time $mom_delay_value }
default { set delay_time $mom_delay_revs }
}
}

#=============================================================
proc MOM_before_motion { } {
#=============================================================
global mom_motion_event mom_motion_type

FEEDRATE_SET

switch $mom_motion_type {
ENGAGE { PB_engage_move }
APPROACH { PB_approach_move }
FIRSTCUT { catch {PB_first_cut} }
RETRACT { PB_retract_move }
RETURN { catch {PB_return_move} }
default {}
}

if { [llength [info commands PB_CMD_kin_before_motion] ] } { PB_CMD_kin_before_motion }
if { [llength [info commands PB_CMD_before_motion] ] } { PB_CMD_before_motion }
}

#=============================================================
proc MOM_start_of_group { } {
#=============================================================
global mom_sys_group_output mom_group_name group_level ptp_file_name
global mom_sequence_number mom_sequence_increment mom_sequence_frequency
global mom_sys_ptp_output pb_start_of_program_flag

if { ![hiset group_level] } {
set group_level 0
return
}

if { [hiset mom_sys_group_output] } {
if { ![string compare $mom_sys_group_output “OFF”] } {
set group_level 0
return
}
}

if { [hiset group_level] } {
incr group_level
} else {
set group_level 1
}

if { $group_level > 1 } {
return
}

SEQNO_RESET ; #<4133654>
MOM_reset_sequence $mom_sequence_number $mom_sequence_increment $mom_sequence_frequency

if { [info exists ptp_file_name] } {
MOM_close_output_file $ptp_file_name
MOM_start_of_program
if { ![string compare $mom_sys_ptp_output “ON”] } {
MOM_open_output_file $ptp_file_name
}
} else {
MOM_start_of_program
}

PB_start_of_program
set pb_start_of_program_flag 1
}

#=============================================================
proc MOM_machine_mode { } {
#=============================================================
global pb_start_of_program_flag
global mom_operation_name mom_sys_change_mach_operation_name

set mom_sys_change_mach_operation_name $mom_operation_name

if { $pb_start_of_program_flag == 0 } {
PB_start_of_program
set pb_start_of_program_flag 1
}

For simple mill-turn

if { [llength [info commands PB_machine_mode] ] } {
if { [catch {PB_machine_mode} res] } {
CATCH_WARNING “$res”
}
}
}

#=============================================================
proc PB_FORCE { option args } {
#=============================================================
set adds [join $args]
if { [info exists option] && [llength $adds] } {
lappend cmd MOM_force
lappend cmd $option
lappend cmd [join $adds]
eval [join $cmd]
}
}

#=============================================================
proc PB_SET_RAPID_MOD { mod_list blk_list ADDR NEW_MOD_LIST } {
#=============================================================
upvar $ADDR addr
upvar $NEW_MOD_LIST new_mod_list
global mom_cycle_spindle_axis traverse_axis1 traverse_axis2

set new_mod_list [list]

foreach mod $mod_list {
switch $mod {
“rapid1” {
set elem a d d r ( addr( addr(traverse_axis1)
if { [lsearch $blk_list $elem] >= 0 } {
lappend new_mod_list $elem
}
}
“rapid2” {
set elem a d d r ( addr( addr(traverse_axis2)
if { [lsearch $blk_list $elem] >= 0 } {
lappend new_mod_list $elem
}
}
“rapid3” {
set elem a d d r ( addr( addr(mom_cycle_spindle_axis)
if { [lsearch $blk_list $elem] >= 0 } {
lappend new_mod_list $elem
}
}
default {
set elem $mod
if { [lsearch $blk_list $elem] >= 0 } {
lappend new_mod_list $elem
}
}
}
}
}

########################

Redefine FEEDRATE_SET

########################
if { [llength [info commands ugpost_FEEDRATE_SET] ] } {
rename ugpost_FEEDRATE_SET “”
}

if { [llength [info commands FEEDRATE_SET] ] } {
rename FEEDRATE_SET ugpost_FEEDRATE_SET
} else {
proc ugpost_FEEDRATE_SET {} {}
}

#=============================================================
proc FEEDRATE_SET { } {
#=============================================================
if { [llength [info commands PB_CMD_kin_feedrate_set] ] } {
PB_CMD_kin_feedrate_set
} else {
ugpost_FEEDRATE_SET
}
}

############## EVENT HANDLING SECTION ################

#=============================================================
proc MOM_auxfun { } {
#=============================================================
MOM_do_template auxfun
}

#=============================================================
proc MOM_bore { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE
CYCLE_SET
}

#=============================================================
proc MOM_bore_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_bore_back { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE_BACK
CYCLE_SET
}

#=============================================================
proc MOM_bore_back_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore_back
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_bore_drag { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE_DRAG
CYCLE_SET
}

#=============================================================
proc MOM_bore_drag_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore_drag
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_bore_dwell { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE_DWELL
CYCLE_SET
}

#=============================================================
proc MOM_bore_dwell_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore_dwell
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_bore_manual { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE_MANUAL
CYCLE_SET
}

#=============================================================
proc MOM_bore_manual_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore_manual
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_bore_manual_dwell { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE_MANUAL_DWELL
CYCLE_SET
}

#=============================================================
proc MOM_bore_manual_dwell_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore_manual_dwell
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_bore_no_drag { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name BORE_NO_DRAG
CYCLE_SET
}

#=============================================================
proc MOM_bore_no_drag_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_bore_no_drag
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_circular_move { } {
#=============================================================

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

CIRCLE_SET
MOM_do_template circular_move
}

#=============================================================
proc MOM_clamp { } {
#=============================================================
global mom_clamp_axis
global mom_clamp_status
global mom_clamp_text
}

#=============================================================
proc MOM_coolant_off { } {
#=============================================================
COOLANT_SET
MOM_do_template coolant_off
}

#=============================================================
proc MOM_coolant_on { } {
#=============================================================
COOLANT_SET
}

#=============================================================
proc MOM_cutcom_on { } {
#=============================================================
CUTCOM_SET

global mom_cutcom_adjust_register
set cutcom_register_min 1
set cutcom_register_max 99
if { [info exists mom_cutcom_adjust_register] } {
if { $mom_cutcom_adjust_register < $cutcom_register_min ||
$mom_cutcom_adjust_register > $cutcom_register_max } {
CATCH_WARNING “CUTCOM register $mom_cutcom_adjust_register must be within the range between 1 and 99”
}
}
}

#=============================================================
proc MOM_cutcom_off { } {
#=============================================================
CUTCOM_SET
MOM_do_template cutcom_off
}

#=============================================================
proc MOM_cycle_off { } {
#=============================================================
MOM_do_template cycle_off
}

#=============================================================
proc MOM_cycle_plane_change { } {
#=============================================================
global cycle_init_flag
global mom_cycle_tool_axis_change
global mom_cycle_clearance_plane_change

set cycle_init_flag TRUE
}

#=============================================================
proc MOM_delay { } {
#=============================================================
PB_DELAY_TIME_SET
MOM_do_template delay
}

#=============================================================
proc MOM_drill { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name DRILL
CYCLE_SET
}

#=============================================================
proc MOM_drill_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_drill
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_drill_break_chip { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name DRILL_BREAK_CHIP
CYCLE_SET
}

#=============================================================
proc MOM_drill_break_chip_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_drill_break_chip
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_drill_deep { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name DRILL_DEEP
CYCLE_SET
}

#=============================================================
proc MOM_drill_deep_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_drill_deep
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_drill_dwell { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name DRILL_DWELL
CYCLE_SET
}

#=============================================================
proc MOM_drill_dwell_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_drill_dwell
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_drill_text { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name DRILL_TEXT
CYCLE_SET
}

#=============================================================
proc MOM_drill_text_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

set cycle_init_flag FALSE
}

#=============================================================
proc MOM_end_of_path { } {
#=============================================================
global mom_sys_add_cutting_time mom_sys_add_non_cutting_time
global mom_cutting_time mom_machine_time

Accumulated time should be in minutes.

set mom_cutting_time [expr $mom_cutting_time + $mom_sys_add_cutting_time]
set mom_machine_time [expr $mom_machine_time + $mom_sys_add_cutting_time + $mom_sys_add_non_cutting_time]
MOM_reload_variable mom_cutting_time
MOM_reload_variable mom_machine_time

if [llength [info commands PB_CMD_kin_end_of_path] ] {
PB_CMD_kin_end_of_path
}

global mom_sys_in_operation
set mom_sys_in_operation 0
}

#=============================================================
proc MOM_end_of_subop_path { } {
#=============================================================
}

#=============================================================
proc MOM_first_move { } {
#=============================================================
global mom_feed_rate mom_feed_rate_per_rev mom_motion_type
global mom_kin_max_fpm mom_motion_event
COOLANT_SET ; CUTCOM_SET ; SPINDLE_SET ; RAPID_SET
catch { MOM_$mom_motion_event }
}

#=============================================================
proc MOM_first_tool { } {
#=============================================================
global mom_sys_first_tool_handled

First tool only gets handled once

if { [info exists mom_sys_first_tool_handled] } {
MOM_tool_change
return
}

set mom_sys_first_tool_handled 1

MOM_tool_change
}

#=============================================================
proc MOM_from_move { } {
#=============================================================
global mom_feed_rate mom_feed_rate_per_rev mom_motion_type mom_kin_max_fpm
COOLANT_SET ; CUTCOM_SET ; SPINDLE_SET ; RAPID_SET
}

#=============================================================
proc MOM_gohome_move { } {
#=============================================================
MOM_rapid_move
}

#=============================================================
proc MOM_head { } {
#=============================================================
global mom_head_name
}

#=============================================================
proc MOM_Head { } {
#=============================================================
MOM_head
}

#=============================================================
proc MOM_HEAD { } {
#=============================================================
MOM_head
}

#=============================================================
proc MOM_initial_move { } {
#=============================================================
global mom_feed_rate mom_feed_rate_per_rev mom_motion_type
global mom_kin_max_fpm mom_motion_event
COOLANT_SET ; CUTCOM_SET ; SPINDLE_SET ; RAPID_SET

global mom_programmed_feed_rate
if { [EQ_is_equal $mom_programmed_feed_rate 0] } {
MOM_rapid_move
} else {
MOM_linear_move
}
}

#=============================================================
proc MOM_insert { } {
#=============================================================
global mom_Instruction
PB_CMD_MOM_insert
}

#=============================================================
proc MOM_instance_operation_handler { } {
#=============================================================
global mom_handle_instanced_operations
}

#=============================================================
proc MOM_laserpower { } {
#=============================================================
global mom_power_level
}

#=============================================================
proc MOM_length_compensation { } {
#=============================================================
TOOL_SET MOM_length_compensation
MOM_do_template tool_length_adjust
}

#=============================================================
proc MOM_linear_move { } {
#=============================================================

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

global first_linear_move

if { !$first_linear_move } {
PB_first_linear_move
incr first_linear_move
}

PB_CMD_suppress_linear_block_plane_code
MOM_do_template linear_move
}

#=============================================================
proc MOM_load_tool { } {
#=============================================================
global mom_tool_change_type mom_manual_tool_change
global mom_tool_number mom_next_tool_number
global mom_sys_tool_number_max mom_sys_tool_number_min

if { $mom_tool_number < $mom_sys_tool_number_min ||
$mom_tool_number > $mom_sys_tool_number_max } {

  global mom_warning_infoset mom_warning_info "Tool number to be output ($mom_tool_number) exceeds limits of\($mom_sys_tool_number_min/$mom_sys_tool_number_max)"MOM_catch_warning

}

}

#=============================================================
proc MOM_lock_axis { } {
#=============================================================
global mom_lock_axis
global mom_lock_axis_plane
global mom_lock_axis_value
}

#=============================================================
proc MOM_operator_message { } {
#=============================================================
global mom_operator_message
PB_CMD_MOM_operator_message
}

#=============================================================
proc MOM_opskip_off { } {
#=============================================================
global mom_opskip_text
PB_CMD_MOM_opskip_off
}

#=============================================================
proc MOM_opskip_on { } {
#=============================================================
global mom_opskip_text
PB_CMD_MOM_opskip_on
}

#=============================================================
proc MOM_opstop { } {
#=============================================================
MOM_do_template opstop
}

#=============================================================
proc MOM_origin { } {
#=============================================================
global mom_X
global mom_Y
global mom_Z
global mom_origin_text
}

#=============================================================
proc MOM_power { } {
#=============================================================
global mom_power_value
global mom_power_text
}

#=============================================================
proc MOM_pprint { } {
#=============================================================
global mom_pprint
PB_CMD_MOM_pprint
}

#=============================================================
proc MOM_prefun { } {
#=============================================================
MOM_do_template prefun
}

#=============================================================
proc MOM_rapid_move { } {
#=============================================================
global rapid_spindle_inhibit rapid_traverse_inhibit
global spindle_first is_from
global mom_cycle_spindle_axis traverse_axis1 traverse_axis2
global mom_motion_event

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

set spindle_first NONE

set aa(0) X ; set aa(1) Y ; set aa(2) Z
RAPID_SET
set rapid_spindle_blk {G_adjust G_motion G_mode X Y Z H}
set rapid_spindle_x_blk {G_adjust G_motion G_mode X H}
set rapid_spindle_y_blk {G_adjust G_motion G_mode Y H}
set rapid_spindle_z_blk {G_adjust G_motion G_mode Z H}
set rapid_traverse_blk {G_motion G_mode X Y Z S M_spindle}
set rapid_traverse_xy_blk {G_motion G_mode X Y S M_spindle}
set rapid_traverse_yz_blk {G_motion G_mode Y Z S M_spindle}
set rapid_traverse_xz_blk {G_motion G_mode X Z S M_spindle}
set rapid_traverse_mod {}
set rapid_spindle_mod {}

global mom_sys_control_out mom_sys_control_in
set co “ m o m s y s c o n t r o l o u t " s e t c i " mom_sys_control_out" set ci " moms​ysc​ontrolo​ut"setci"mom_sys_control_in”

if { ![info exists mom_cycle_spindle_axis] } {
set mom_cycle_spindle_axis 2
}
if { ![info exists spindle_first] } {
set spindle_first NONE
}
if { ![info exists rapid_spindle_inhibit] } {
set rapid_spindle_inhibit FALSE
}
if { ![info exists rapid_traverse_inhibit] } {
set rapid_traverse_inhibit FALSE
}

switch $mom_cycle_spindle_axis {
0 {
if [llength $rapid_spindle_x_blk] {
set spindle_block rapid_spindle_x
PB_SET_RAPID_MOD $rapid_spindle_mod $rapid_spindle_x_blk aa mod_spindle
} else {
set spindle_block “”
}
if [llength $rapid_traverse_yz_blk] {
set traverse_block rapid_traverse_yz
PB_SET_RAPID_MOD $rapid_traverse_mod $rapid_traverse_yz_blk aa mod_traverse
} else {
set traverse_block “”
}
}

  1 {if [llength $rapid_spindle_y_blk] {set spindle_block  rapid_spindle_yPB_SET_RAPID_MOD $rapid_spindle_mod $rapid_spindle_y_blk aa mod_spindle} else {set spindle_block  ""}if [llength $rapid_traverse_xz_blk] {set traverse_block rapid_traverse_xzPB_SET_RAPID_MOD $rapid_traverse_mod $rapid_traverse_xz_blk aa mod_traverse} else {set traverse_block  ""}}2 {if [llength $rapid_spindle_z_blk] {set spindle_block  rapid_spindle_zPB_SET_RAPID_MOD $rapid_spindle_mod $rapid_spindle_z_blk aa mod_spindle} else {set spindle_block  ""}if [llength $rapid_traverse_xy_blk] {set traverse_block rapid_traverse_xyPB_SET_RAPID_MOD $rapid_traverse_mod $rapid_traverse_xy_blk aa mod_traverse} else {set traverse_block  ""}}default {set spindle_block  rapid_spindleset traverse_block rapid_traversePB_SET_RAPID_MOD $rapid_spindle_mod $rapid_spindle_blk aa mod_spindlePB_SET_RAPID_MOD $rapid_traverse_mod $rapid_traverse_blk aa mod_traverse}

}

if { ![string compare $spindle_first “TRUE”] } {
if { ![string compare $rapid_spindle_inhibit “FALSE”] } {
if { [string compare $spindle_block “”] } {
PB_FORCE Once $mod_spindle
MOM_do_template KaTeX parse error: Expected 'EOF', got '}' at position 24: …block }̲ else { …co Rapid Spindle Block is empty! $ci"
}
}
if { ![string compare $rapid_traverse_inhibit “FALSE”] } {
if { [string compare $traverse_block “”] } {
PB_FORCE Once $mod_traverse
MOM_do_template KaTeX parse error: Expected 'EOF', got '}' at position 25: …block }̲ else { …co Rapid Traverse Block is empty! $ci"
}
}
} elseif { ![string compare $spindle_first “FALSE”] } {
if { ![string compare $rapid_traverse_inhibit “FALSE”] } {
if { [string compare $traverse_block “”] } {
PB_FORCE Once $mod_traverse
MOM_do_template KaTeX parse error: Expected 'EOF', got '}' at position 25: …block }̲ else { …co Rapid Traverse Block is empty! $ci"
}
}
if { ![string compare $rapid_spindle_inhibit “FALSE”] } {
if { [string compare $spindle_block “”] } {
PB_FORCE Once $mod_spindle
MOM_do_template KaTeX parse error: Expected 'EOF', got '}' at position 24: …block }̲ else { …co Rapid Spindle Block is empty! $ci"
}
}
} else {
PB_FORCE Once $mod_traverse
MOM_do_template rapid_traverse
}
}

#=============================================================
proc MOM_rotate { } {
#=============================================================
global mom_rotate_axis_type
global mom_rotation_mode
global mom_rotation_direction
global mom_rotation_angle
global mom_rotation_reference_mode
global mom_rotation_text
}

#=============================================================
proc MOM_select_head { } {
#=============================================================
global mom_head_type
global mom_head_text
}

#=============================================================
proc MOM_sequence_number { } {
#=============================================================
global mom_sequence_mode
global mom_sequence_number
global mom_sequence_increment
global mom_sequence_frequency
global mom_sequence_text
SEQNO_SET
}

#=============================================================
proc MOM_set_axis { } {
#=============================================================
global mom_axis_position
global mom_axis_position_value
}

#=============================================================
proc MOM_set_modes { } {
#=============================================================
MODES_SET
}

#=============================================================
proc MOM_set_polar { } {
#=============================================================
global mom_coordinate_output_mode
}

#=============================================================
proc MOM_spindle_rpm { } {
#=============================================================
SPINDLE_SET
MOM_force Once S M_spindle
MOM_do_template spindle_rpm
}

#=============================================================
proc MOM_spindle_off { } {
#=============================================================
MOM_do_template spindle_off
}

#=============================================================
proc MOM_start_of_path { } {
#=============================================================
global mom_sys_in_operation
set mom_sys_in_operation 1

global first_linear_move ; set first_linear_move 0
TOOL_SET MOM_start_of_path

global mom_sys_add_cutting_time mom_sys_add_non_cutting_time
global mom_sys_machine_time mom_machine_time
set mom_sys_add_cutting_time 0.0
set mom_sys_add_non_cutting_time 0.0
set mom_sys_machine_time $mom_machine_time

if [llength [info commands PB_CMD_kin_start_of_path] ] {
PB_CMD_kin_start_of_path
}

PB_CMD_start_of_operation_force_addresses
}

#=============================================================
proc MOM_start_of_subop_path { } {
#=============================================================
}

#=============================================================
proc MOM_stop { } {
#=============================================================
MOM_do_template stop
}

#=============================================================
proc MOM_tap { } {
#=============================================================
global cycle_name
global cycle_init_flag

set cycle_init_flag TRUE
set cycle_name TAP
CYCLE_SET
}

#=============================================================
proc MOM_tap_move { } {
#=============================================================
global cycle_init_flag

global mom_sys_abort_next_event
if { [info exists mom_sys_abort_next_event] } {
if { [llength [info commands PB_CMD_kin_abort_event]] } {
PB_CMD_kin_abort_event
}
}

MOM_do_template cycle_tap
set cycle_init_flag FALSE
}

#=============================================================
proc MOM_text { } {
#=============================================================
global mom_user_defined_text
PB_CMD_MOM_text
}

#=============================================================
proc MOM_tool_change { } {
#=============================================================
global mom_tool_change_type mom_manual_tool_change
global mom_tool_number mom_next_tool_number
global mom_sys_tool_number_max mom_sys_tool_number_min

if { $mom_tool_number < $mom_sys_tool_number_min ||
$mom_tool_number > $mom_sys_tool_number_max } {

  global mom_warning_infoset mom_warning_info "Tool number to be output ($mom_tool_number) exceeds limits of\($mom_sys_tool_number_min/$mom_sys_tool_number_max)"MOM_catch_warning

}

if { [info exists mom_tool_change_type] } {
switch $mom_tool_change_type {
MANUAL { PB_manual_tool_change }
AUTO { PB_auto_tool_change }
}
} elseif { [info exists mom_manual_tool_change] } {
if { ![string compare $mom_manual_tool_change “TRUE”] } {
PB_manual_tool_change
}
}
}

#=============================================================
proc MOM_tool_preselect { } {
#=============================================================
global mom_tool_preselect_number mom_tool_number mom_next_tool_number
global mom_sys_tool_number_max mom_sys_tool_number_min

if { [info exists mom_tool_preselect_number] } {
if { $mom_tool_preselect_number < $mom_sys_tool_number_min ||
$mom_tool_preselect_number > $mom_sys_tool_number_max } {

     global mom_warning_infoset mom_warning_info "Preselected Tool number ($mom_tool_preselect_number) exceeds limits of\($mom_sys_tool_number_min/$mom_sys_tool_number_max)"MOM_catch_warning}set mom_next_tool_number $mom_tool_preselect_number

}

MOM_do_template tool_preselect
}

#=============================================================
proc MOM_workpiece_load { } {
#=============================================================
global mom_spindle_number
}

#=============================================================
proc MOM_workpiece_takeover { } {
#=============================================================
global mom_spindle_2_position
global mom_takeover_csys
}

#=============================================================
proc MOM_workpiece_unload { } {
#=============================================================
global mom_spindle_number
}

#=============================================================
proc MOM_zero { } {
#=============================================================
global mom_work_coordinate_number
}

#=============================================================
proc PB_approach_move { } {
#=============================================================
}

#=============================================================
proc PB_auto_tool_change { } {
#=============================================================
global mom_tool_number mom_next_tool_number
if { ![info exists mom_next_tool_number] } {
set mom_next_tool_number $mom_tool_number
}

MOM_force Once G_mode G Z
MOM_do_template tool_change
PB_CMD_tool_change_force_addresses
MOM_force Once T M
MOM_do_template tool_change_1
MOM_do_template tool_change_2
}

#=============================================================
proc PB_engage_move { } {
#=============================================================
}

#=============================================================
proc PB_feedrates { } {
#=============================================================
}

#=============================================================
proc PB_first_cut { } {
#=============================================================
}

#=============================================================
proc PB_first_linear_move { } {
#=============================================================
global mom_sys_first_linear_move

Set this variable to signal 1st linear move has been handled.

set mom_sys_first_linear_move 1

}

#=============================================================
proc PB_manual_tool_change { } {
#=============================================================
PB_CMD_tool_change_force_addresses
MOM_do_template stop
}

#=============================================================
proc PB_retract_move { } {
#=============================================================
}

#=============================================================
proc PB_return_move { } {
#=============================================================
}

#=============================================================
proc PB_start_of_program { } {
#=============================================================

if [llength [info commands PB_CMD_kin_start_of_program] ] {
PB_CMD_kin_start_of_program
}

MOM_set_seq_off
MOM_do_template rewind_stop_code
MOM_set_seq_on
MOM_force Once G_cutcom G_plane G_mode
MOM_do_template absolute_mode
PB_CMD_fix_RAPID_SET

if [llength [info commands PB_CMD_kin_start_of_program_2] ] {
PB_CMD_kin_start_of_program_2
}
}

#=============================================================
proc PB_CMD_FEEDRATE_NUMBER { } {
#=============================================================

This custom command is called by FEEDRATE_SET;

it allows you to modify the feed rate number after being

calculated by the system.

#<03-13-08 gsl> - Added use of frn factor (defined in ugpost_base.tcl) & max frn here

Use global frn factor (defined as 1.0 in ugpost_base.tcl) or

define a custom one here

global mom_feed_rate_number
global mom_sys_frn_factor
global mom_kin_max_frn

set mom_sys_frn_factor 1.0

set f 0.0

if { [info exists mom_feed_rate_number] } {
set f [expr $mom_feed_rate_number * $mom_sys_frn_factor]
if { [EQ_is_gt $f $mom_kin_max_frn] } {
set f $mom_kin_max_frn
}
}

return $f
}

#=============================================================
proc PB_CMD_MOM_insert { } {
#=============================================================

Default handler for UDE MOM_insert

- Do not attach it to any event!

This procedure is executed when the Insert command is activated.

global mom_Instruction
MOM_output_literal “$mom_Instruction”
}

#=============================================================
proc PB_CMD_MOM_operator_message { } {
#=============================================================

Default handler for UDE MOM_operator_message

- Do not attach it to any event!

This procedure is executed when the Operator Message command is activated.

global mom_operator_message mom_operator_message_defined
global mom_operator_message_status
global ptp_file_name group_output_file mom_group_name
global mom_sys_commentary_output
global mom_sys_control_in
global mom_sys_control_out
global mom_sys_ptp_output
global mom_post_in_simulation

if { [info exists mom_operator_message_defined] && $mom_operator_message_defined == 0 } {
return
}

if { [string compare “ON” $mom_operator_message] && [string compare “OFF” $mom_operator_message] } {

  set brac_start [string first \( $mom_operator_message]set brac_end   [string last  \) $mom_operator_message]if { $brac_start != 0 } {set text_string "("} else {set text_string ""}append text_string $mom_operator_messageif { $brac_end == -1 || \$brac_end != [expr [string length $mom_operator_message] -1] } {append text_string ")"}set st [MOM_set_seq_off]# Suspend output to PTPMOM_close_output_file   $ptp_file_nameif { [info exists mom_group_name] && [info exists group_output_file($mom_group_name)] } {MOM_close_output_file $group_output_file($mom_group_name)}# 5767232 -# 6686893 - seq num were output in nx6# if { [string match "on" $st] } { MOM_suppress once N }#<01Jun2011 wbh> Only output text to commentary file when postprocessingif { ![info exists mom_post_in_simulation] || $mom_post_in_simulation == 0 } {MOM_output_literal $text_string}# Resume output to PTPif { ![string compare "ON" $mom_sys_ptp_output] } {MOM_open_output_file    $ptp_file_name}if { [info exists mom_group_name] && [info exists group_output_file($mom_group_name)] } {MOM_open_output_file $group_output_file($mom_group_name)}if { [string match "on" $st] } { MOM_set_seq_on }set need_commentary $mom_sys_commentary_outputset mom_sys_commentary_output OFFregsub -all {[)]} $text_string $mom_sys_control_in  text_stringregsub -all {[(]} $text_string $mom_sys_control_out text_stringMOM_output_literal $text_stringset mom_sys_commentary_output $need_commentary

} else {
set mom_operator_message_status $mom_operator_message
}
}

#=============================================================
proc PB_CMD_MOM_opskip_off { } {
#=============================================================

Default handler for UDE MOM_opskip_off

- Do not attach it to any event!

This procedure is executed when the Optional skip command is activated.

global mom_sys_opskip_block_leader
MOM_set_line_leader off $mom_sys_opskip_block_leader
}

#=============================================================
proc PB_CMD_MOM_opskip_on { } {
#=============================================================

Default handler for UDE MOM_opskip_on

- Do not attach it to any event!

This procedure is executed when the Optional skip command is activated.

global mom_sys_opskip_block_leader
MOM_set_line_leader always $mom_sys_opskip_block_leader
}

#=============================================================
proc PB_CMD_MOM_pprint { } {
#=============================================================

Default handler for UDE MOM_pprint

- Do not attach it to any event!

This procedure is executed when the PPrint command is activated.

global mom_pprint_defined

if { [info exists mom_pprint_defined] } {
if { $mom_pprint_defined == 0 } {
return
}
}

PPRINT_OUTPUT
}

#=============================================================
proc PB_CMD_MOM_text { } {
#=============================================================

Default handler for UDE MOM_text

- Do not attach it to any event!

This procedure is executed when the Text command is activated.

global mom_user_defined_text mom_record_fields
global mom_sys_control_out mom_sys_control_in
global mom_record_text mom_pprint set mom_Instruction mom_operator_message
global mom_pprint_defined mom_operator_message_defined

switch $mom_record_fields(0) {
“PPRINT”
{
set mom_pprint_defined 1
set mom_pprint $mom_record_text
MOM_pprint
}
“INSERT”
{
set mom_Instruction $mom_record_text
MOM_insert
}
“DISPLY”
{
set mom_operator_message_defined 1
set mom_operator_message KaTeX parse error: Expected 'EOF', got '}' at position 58: …ssage }̲ default …{mom_sys_control_out} m o m u s e r d e f i n e d t e x t {mom_user_defined_text} momu​serd​efinedt​ext{mom_sys_control_in}"
}
}
}
}

#=============================================================
proc PB_CMD__config_post_options { } {
#=============================================================

This command should be called by Start-of-Program event;

it enables users to set options (not via UI) that would

affect the behavior and output of this post.

Comment out next line to activate this command

return

- Feed mode for RETRACT motion has been handled as RAPID,

next option enables users to treat RETRACT as CONTOURing.

if { ![info exists ::mom_sys_retract_feed_mode] } {
set ::mom_sys_retract_feed_mode “CONTOUR”
}
}

#=============================================================
proc PB_CMD__manage_part_attributes { } {
#=============================================================

This command allows the user to manage the MOM variables

generated for the part attributes, in case of conflicts.

==> This command is executed automatically when present in

the post. DO NOT add or call it in any event or command.

This command should only be called by MOM__part_attributes!

if { ![CALLED_BY “MOM__part_attributes”] } {
return
}

#+++++++++++++++++++++++++++++++++++++

You may manage part attributes here

#+++++++++++++++++++++++++++++++++++++
}

#=============================================================
proc PB_CMD_abort_event { } {
#=============================================================

This command can be called to abort an event based on the

flag being set by other handler under certain conditions,

such as an invalid tool axis vector.

Users can set the global variable mom_sys_abort_next_event to

different severity levels throughout the post and designate

how to handle different conditions in this command.

- Rapid, linear, circular and cycle move events have this trigger

built in by default in PB6.0.

06-17-13 gsl - Do not abort event, by default, when signal is “1”.

07-16-15 gsl - Added level 3 handling

global mom_sys_abort_next_event

if { [info exists mom_sys_abort_next_event] } {

  switch $mom_sys_abort_next_event {2 -3 {# User may choose to abort NX/Postset __abort_post 0if { $__abort_post } {set msg "NX/Post Aborted: Illegal Move ($mom_sys_abort_next_event)"if { [info exists ::mom_post_in_simulation] && $::mom_post_in_simulation == "MTD" } {# In simulation, user will choose "Cancel" to stop the process.PAUSE MOM_abort $msg} else {MOM_abort $msg}}# Level 2 only aborts current event; level 3 will abort entire motion.if { $mom_sys_abort_next_event == 2 } {unset mom_sys_abort_next_event}CATCH_WARNING "Event aborted!"MOM_abort_event}default {unset mom_sys_abort_next_eventCATCH_WARNING "Event warned!"}}

}
}

#=============================================================
proc PB_CMD_ask_machine_type { } {
#=============================================================

Utility to return machine type per mom_kin_machine_type

Revisions:

#-----------

02-26-09 gsl - Initial version

global mom_kin_machine_type

if { [string match “wedm” $mom_kin_machine_type] } {
return WEDM
} elseif { [string match “axis” $mom_kin_machine_type] } {
return MILL
} elseif { [string match “lathe” $mom_kin_machine_type] } {
return TURN
} else {
return $mom_kin_machine_type
}
}

#=============================================================
proc PB_CMD_enable_ball_center_output { } {
#=============================================================

This command can be added to the Start-of-Program event marker

to enable ball-center output for ANY milling operations that use

one of the following 3 types (mom_tool_type) of tool:

a. “Milling Tool-Ball Mill”

b. “Spherical Mill”

c. “Milling Tool-5 Parameters” whose tool diameter is 2 times of the corner radius.

- Only qualified operations will cause NX/Post to produce ball-center outputs.

- The condition is verified for every operation.

- Ball centers are computed for every move including cutting and non-cutting motions in

either standard or turbo process mode.

- Legacy command “PB_CMD_center_of_ball_output”, if present in the post, will be disabled.

This command should be called in the Start-of-Program event

if { ![CALLED_BY “PB_start_of_program”] } {
return
}

This command only works with NX9 & beyond.

if { [expr [string trim [MOM_ask_env_var UGII_MAJOR_VERSION]] < 9] } {
CATCH_WARNING “[info level 0] is only functional with NX9 and newer!”
return
}

Disable legacy command

if { [CMD_EXIST PB_CMD_center_of_ball_output] } {
uplevel #0 {
proc PB_CMD_center_of_ball_output { } { }
}
}

Enable new capability

global mom_sys_enable_ball_center_output
set mom_sys_enable_ball_center_output 1

Define event handler

if $mom_sys_enable_ball_center_output {
uplevel #0 {

  #-------------------------------------------------------------------------------proc MOM_ball_center_output { } {# This event will be triggered before Start-of-Path when# an operation is qualified to produce ball-center outputs.## This command may be customized as needed.#}#-------------------------------------------------------------------------------}

}

}

#=============================================================
proc PB_CMD_end_of_alignment_character { } {
#=============================================================

This command restores sequnece number back to orignal setting.

This command may be used with the command “PM_CMD_start_of_alignment_character”

global mom_sys_leader saved_seq_num
if { [info exists saved_seq_num] } {
set mom_sys_leader(N) $saved_seq_num
}
}

#=============================================================
proc PB_CMD_fix_RAPID_SET { } {
#=============================================================

This command is provided to overwrite the system RAPID_SET

(defined in ugpost_base.tcl) in order to correct the problem

with workplane change that doesn’t account for +/- directions

along X or Y principal axis. It also fixes the problem that

the First Move was never identified correctly to force

the output of the 1st point.

The original command has been renamed as ugpost_RAPID_SET.

- This command may be attached to the “Start of Program” event marker.

Revisions:

#-----------

02-18-08 gsl - Initial version

02-26-09 gsl - Used mom_kin_machine_type to derive machine mode when it’s UNDEFINED.

08-18-15 sws - PR7294525 : Use mom_current_motion to detect first move & initial move

Only redefine RAPID_SET once, since ugpost_base is only loaded once.

if { ![CMD_EXIST ugpost_RAPID_SET] } {
if { [CMD_EXIST RAPID_SET] } {
rename RAPID_SET ugpost_RAPID_SET
}
} else {
return
}

#***********
uplevel #0 {

#====================
proc RAPID_SET { } {
#====================

if { [CMD_EXIST PB_CMD_set_principal_axis] } {
PB_CMD_set_principal_axis
}

global mom_cycle_spindle_axis mom_sys_work_plane_change
global traverse_axis1 traverse_axis2 mom_motion_event mom_machine_mode
global mom_pos mom_prev_pos mom_from_pos mom_last_pos mom_sys_home_pos
global mom_sys_tool_change_pos
global spindle_first rapid_spindle_inhibit rapid_traverse_inhibit
global mom_current_motion

if { ![info exists mom_from_pos(KaTeX parse error: Expected 'EOF', got '&' at position 26: …spindle_axis)] &̲& \ [i…mom_cycle_spindle_axis)] } {

  set mom_from_pos(0) $mom_sys_home_pos(0)set mom_from_pos(1) $mom_sys_home_pos(1)set mom_from_pos(2) $mom_sys_home_pos(2)

} elseif { ![info exists mom_sys_home_pos(KaTeX parse error: Expected 'EOF', got '&' at position 26: …spindle_axis)] &̲& \ …mom_cycle_spindle_axis)] } {

  set mom_sys_home_pos(0) $mom_from_pos(0)set mom_sys_home_pos(1) $mom_from_pos(1)set mom_sys_home_pos(2) $mom_from_pos(2)

} elseif { ![info exists mom_sys_home_pos(KaTeX parse error: Expected 'EOF', got '&' at position 26: …spindle_axis)] &̲& \ …mom_cycle_spindle_axis)] } {

  set mom_from_pos(0) 0.0 ; set mom_sys_home_pos(0) 0.0set mom_from_pos(1) 0.0 ; set mom_sys_home_pos(1) 0.0set mom_from_pos(2) 0.0 ; set mom_sys_home_pos(2) 0.0

}

if { ![info exists mom_sys_tool_change_pos(KaTeX parse error: Expected 'EOF', got '}' at position 26: …spindle_axis)] }̲ { set mo…mom_cycle_spindle_axis) 100000.0
}

set is_initial_move [string match “initial_move” $mom_current_motion]
set is_first_move [string match “first_move” $mom_current_motion]

if { $is_initial_move || KaTeX parse error: Expected 'EOF', got '}' at position 15: is_first_move }̲ { set mo…mom_cycle_spindle_axis) m o m s y s t o o l c h a n g e p o s ( mom_sys_tool_change_pos( moms​yst​oolc​hangep​os(mom_cycle_spindle_axis)
} else {
if { [info exists mom_last_pos(KaTeX parse error: Expected 'EOF', got '}' at position 31: …le_axis)] == 0 }̲ { set…mom_cycle_spindle_axis) m o m s y s h o m e p o s ( mom_sys_home_pos( moms​ysh​omep​os(mom_cycle_spindle_axis)
}
}

if { $mom_machine_mode != “MILL” && $mom_machine_mode != “DRILL” } {
# When machine mode is UNDEFINED, ask machine type
if { ![string match “MILL” [PB_CMD_ask_machine_type]] } {
return
}
}

WORKPLANE_SET

set rapid_spindle_inhibit FALSE
set rapid_traverse_inhibit FALSE

if { [EQ_is_lt m o m p o s ( mom_pos( momp​os(mom_cycle_spindle_axis) m o m l a s t p o s ( mom_last_pos( moml​astp​os(mom_cycle_spindle_axis)] } {
set going_lower 1
} else {
set going_lower 0
}

if { ![info exists mom_sys_work_plane_change] } {
set mom_sys_work_plane_change 1
}

Reverse workplane change direction per spindle axis

global mom_spindle_axis

if { [info exists mom_spindle_axis] } {

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# User can temporarily disable the work plane change for rapid moves along non-principal
# spindle axis even when work plane change has been set in the Rapid Move event.
#
# Work plane change, if set, will still be in effect for moves along principal axes.
#
# - This flag has no effect if the work plane change is not set.
#set disable_non_principal_spindle 0switch $mom_cycle_spindle_axis {0 {if [EQ_is_lt $mom_spindle_axis(0) 0.0] {set going_lower [expr abs($going_lower - 1)]}}1 {if [EQ_is_lt $mom_spindle_axis(1) 0.0] {set going_lower [expr abs($going_lower - 1)]}}2 {# Multi-spindle machineif [EQ_is_lt $mom_spindle_axis(2) 0.0] {set going_lower [expr abs($going_lower - 1)]}}}# Per user's choice above, disable work plane change for non-principal spindle axis#if { $disable_non_principal_spindle } {if { ![EQ_is_equal $mom_spindle_axis(0) 1] && \![EQ_is_equal $mom_spindle_axis(1) 1] && \![EQ_is_equal $mom_spindle_axis(0) 1] } {global mom_user_work_plane_changeglobal mom_user_spindle_firstset mom_user_work_plane_change $mom_sys_work_plane_changeset mom_sys_work_plane_change 0if [info exists spindle_first] {set mom_user_spindle_first $spindle_first} else {set mom_user_spindle_first NONE}}}

}

if { $mom_sys_work_plane_change } {

  if { $going_lower } {set spindle_first FALSE} else {set spindle_first TRUE}# Force output in Initial Move and First Move.if { !$is_initial_move && !$is_first_move } {if { [EQ_is_equal $mom_pos($mom_cycle_spindle_axis) $mom_last_pos($mom_cycle_spindle_axis)] } {set rapid_spindle_inhibit TRUE} else {set rapid_spindle_inhibit FALSE}if { [EQ_is_equal $mom_pos($traverse_axis1) $mom_prev_pos($traverse_axis1)] && \[EQ_is_equal $mom_pos($traverse_axis2) $mom_prev_pos($traverse_axis2)] && \[EQ_is_equal $mom_pos(3) $mom_prev_pos(3)] && [EQ_is_equal $mom_pos(4) $mom_prev_pos(4)] } {set rapid_traverse_inhibit TRUE} else {set rapid_traverse_inhibit FALSE}}

} else {
set spindle_first NONE
}

} ;# RAPID_SET

} ;# uplevel
#***********
}

#=============================================================
proc PB_CMD_kin_abort_event { } {
#=============================================================
if { [llength [info commands PB_CMD_abort_event]] } {
PB_CMD_abort_event
}
}

#=============================================================
proc PB_CMD_kin_before_output { } {
#=============================================================

Broker command ensuring PB_CMD_before_output, if present, gets executed

by MOM_before_output.

==> DO NOT add anything here!

==> All customization must be done in PB_CMD_before_output!

==> PB_CMD_before_output MUST NOT call any “MOM_output” commands!

if [llength [info commands PB_CMD_before_output] ] {
PB_CMD_before_output
}
}

#=============================================================
proc PB_CMD_kin_end_of_path { } {
#=============================================================

Record tool time for this operation.

if { [llength [info commands PB_CMD_set_oper_tool_time] ] } {
PB_CMD_set_oper_tool_time
}

Clear tool holder angle used in operation

global mom_use_b_axis
UNSET_VARS mom_use_b_axis
}

#=============================================================
proc PB_CMD_kin_feedrate_set { } {
#=============================================================

This command supercedes the functionalites provided by the

FEEDRATE_SET in ugpost_base.tcl. Post Builder automatically

generates proper call sequences to this command in the

Event handlers.

This command must be used in conjunction with ugpost_base.tcl.

global feed com_feed_rate
global mom_feed_rate_output_mode super_feed_mode feed_mode
global mom_cycle_feed_rate_mode mom_cycle_feed_rate
global mom_cycle_feed_rate_per_rev
global mom_motion_type
global Feed_IPM Feed_IPR Feed_MMPM Feed_MMPR Feed_INV
global mom_sys_feed_param
global mom_sys_cycle_feed_mode

set super_feed_mode $mom_feed_rate_output_mode

set f_pm [ASK_FEEDRATE_FPM]
set f_pr [ASK_FEEDRATE_FPR]

switch $mom_motion_type {

  CYCLE {if { [info exists mom_sys_cycle_feed_mode] } {if { [string compare "Auto" $mom_sys_cycle_feed_mode] } {set mom_cycle_feed_rate_mode $mom_sys_cycle_feed_mode}}if { [info exists mom_cycle_feed_rate_mode] }    { set super_feed_mode $mom_cycle_feed_rate_mode }if { [info exists mom_cycle_feed_rate] }         { set f_pm $mom_cycle_feed_rate }if { [info exists mom_cycle_feed_rate_per_rev] } { set f_pr $mom_cycle_feed_rate_per_rev }}FROM -RETURN -LIFT -TRAVERSAL -GOHOME -GOHOME_DEFAULT -RAPID {SUPER_FEED_MODE_SET RAPID}default {if { [EQ_is_zero $f_pm] && [EQ_is_zero $f_pr] } {SUPER_FEED_MODE_SET RAPID} else {SUPER_FEED_MODE_SET CONTOUR}}

}

Treat RETRACT as cutting when specified

global mom_sys_retract_feed_mode
if { [string match “RETRACT” $mom_motion_type] } {

  if { [info exist mom_sys_retract_feed_mode] && [string match "CONTOUR" $mom_sys_retract_feed_mode] } {if { [EQ_is_zero $f_pm] && [EQ_is_zero $f_pr] } {SUPER_FEED_MODE_SET RAPID} else {SUPER_FEED_MODE_SET CONTOUR}} else {SUPER_FEED_MODE_SET RAPID}

}

set feed_mode $super_feed_mode

Adjust feedrate format per Post output unit again.

global mom_kin_output_unit
if { ![string compare “IN” $mom_kin_output_unit] } {
switch $feed_mode {
MMPM {
set feed_mode “IPM”
CATCH_WARNING “Feedrate mode MMPM changed to IPM”
}
MMPR {
set feed_mode “IPR”
CATCH_WARNING “Feedrate mode MMPR changed to IPR”
}
}
} else {
switch $feed_mode {
IPM {
set feed_mode “MMPM”
CATCH_WARNING “Feedrate mode IPM changed to MMPM”
}
IPR {
set feed_mode “MMPR”
CATCH_WARNING “Feedrate mode IPR changed to MMPR”
}
}
}

switch $feed_mode {
IPM -
MMPM { set feed $f_pm }
IPR -
MMPR { set feed $f_pr }
DPM { set feed [PB_CMD_FEEDRATE_DPM] }
FRN -
INVERSE { set feed [PB_CMD_FEEDRATE_NUMBER] }
default {
CATCH_WARNING “INVALID FEED RATE MODE”
return
}
}

Post Builder provided format for the current mode:

if { [info exists mom_sys_feed_param(${feed_mode},format)] } {
MOM_set_address_format F m o m s y s f e e d p a r a m ( mom_sys_feed_param( moms​ysf​eedp​aram({feed_mode},format)
} else {
switch KaTeX parse error: Expected group after '_' at position 156: …s_format F Feed_̲{feed_mode} }
INVERSE { MOM_set_address_format F Feed_INV }
}
}

Commentary output

set com_feed_rate $f_pm

Execute user’s command, if any.

if { [llength [info commands “PB_CMD_FEEDRATE_SET”]] } {
PB_CMD_FEEDRATE_SET
}
}

#=============================================================
proc PB_CMD_kin_init_new_iks { } {
#=============================================================
global mom_kin_machine_type
global mom_new_iks_exists

Revert legacy dual-head kinematic parameters when new IKS is absent.

if { [string match “5_axis_dual_head” $mom_kin_machine_type] } {
if { ![info exists mom_new_iks_exists] } {
set ugii_version [string trim [MOM_ask_env_var UGII_VERSION]]
if { ![string match “v3” $ugii_version] } {

        if { [CMD_EXIST PB_CMD_revert_dual_head_kin_vars] } {PB_CMD_revert_dual_head_kin_vars}

return
}
}
}

Initialize new IKS parameters.

if { [CMD_EXIST PB_init_new_iks] } {
PB_init_new_iks
}

Users can provide next command to modify or disable new IKS options.

if { [CMD_EXIST PB_CMD_revise_new_iks] } {
PB_CMD_revise_new_iks
}

Revert legacy dual-head kinematic parameters when new IKS is disabled.

if { [string match “5_axis_dual_head” $mom_kin_machine_type] } {
global mom_kin_iks_usage
if { $mom_kin_iks_usage == 0 } {
if { [CMD_EXIST PB_CMD_revert_dual_head_kin_vars] } {
PB_CMD_revert_dual_head_kin_vars
}
}
}
}

#=============================================================
proc PB_CMD_kin_init_probing_cycles { } {
#=============================================================
set cmd PB_CMD_init_probing_cycles
if { [CMD_EXIST “$cmd”] } {
eval $cmd
}
}

#=============================================================
proc PB_CMD_kin_set_csys { } {
#=============================================================

- For mill post -

Output NC code according to CSYS

if { [CMD_EXIST PB_CMD_set_csys] } {
PB_CMD_set_csys
}

Overload IKS params from machine model.

PB_CMD_reload_iks_parameters

In case Axis Rotation has been set to “reverse”

if { [CMD_EXIST PB_CMD_reverse_rotation_vector] } {
PB_CMD_reverse_rotation_vector
}
}

#=============================================================
proc PB_CMD_kin_start_of_path { } {
#=============================================================

- For mill post -

This command is executed at the start of every operation.

It will verify if a new head (post) was loaded and will

then initialize any functionality specific to that post.

It will also restore the master Start of Program &

End of Program event handlers.

–> DO NOT CHANGE THIS COMMAND UNLESS YOU KNOW WHAT YOU ARE DOING.

–> DO NOT CALL THIS COMMAND FROM ANY OTHER CUSTOM COMMAND.

global mom_sys_head_change_init_program

if { [info exists mom_sys_head_change_init_program] } {

  PB_CMD_kin_start_of_programunset mom_sys_head_change_init_program# Load alternate units' parametersif [CMD_EXIST PB_load_alternate_unit_settings] {PB_load_alternate_unit_settingsrename PB_load_alternate_unit_settings ""}# Execute start of head callback in new post's context.global CURRENT_HEADif { [info exists CURRENT_HEAD] && [CMD_EXIST PB_start_of_HEAD__$CURRENT_HEAD] } {PB_start_of_HEAD__$CURRENT_HEAD}# Restore master start & end of program handlersif { [CMD_EXIST "MOM_start_of_program_save"] } {if { [CMD_EXIST "MOM_start_of_program"] } {rename MOM_start_of_program ""}rename MOM_start_of_program_save MOM_start_of_program}if { [CMD_EXIST "MOM_end_of_program_save"] } {if { [CMD_EXIST "MOM_end_of_program"] } {rename MOM_end_of_program ""}rename MOM_end_of_program_save MOM_end_of_program}# Restore master head change event handlerif { [CMD_EXIST "MOM_head_save"] } {if { [CMD_EXIST "MOM_head"] } {rename MOM_head ""}rename MOM_head_save MOM_head}

}

Overload IKS params from machine model.

PB_CMD_reload_iks_parameters

Incase Axis Rotation has been set to “reverse”

if { [CMD_EXIST PB_CMD_reverse_rotation_vector] } {
PB_CMD_reverse_rotation_vector
}

Initialize tool time accumulator for this operation.

if { [CMD_EXIST PB_CMD_init_oper_tool_time] } {
PB_CMD_init_oper_tool_time
}

Force out motion G code at the start of path.

MOM_force once G_motion
}

#=============================================================
proc PB_CMD_kin_start_of_program { } {
#=============================================================

This command will execute the following custom commands for

initialization. They will be executed once at the start of

program and again each time they are loaded as a linked post.

After execution they will be deleted so that they are not

present when a different post is loaded. You may add a call

to any command that you want executed when a linked post is

loaded.

Note when a linked post is called in, the Start of Program

event marker is not executed again.

–> DO NOT REMOVE ANY LINES FROM THIS PROCEDURE UNLESS YOU KNOW

WHAT YOU ARE DOING.

–> DO NOT CALL THIS PROCEDURE FROM ANY

OTHER CUSTOM COMMAND.

global mom_kin_machine_type

set command_list [list]

if { [info exists mom_kin_machine_type] } {
if { ![string match “3_axis_mill” $mom_kin_machine_type] &&
![string match “lathe” $mom_kin_machine_type] } {

     lappend command_list  PB_CMD_kin_init_rotary}

}

lappend command_list PB_CMD_kin_init_new_iks

lappend command_list PB_CMD_init_pivot_offsets
lappend command_list PB_CMD_init_auto_retract
lappend command_list PB_CMD_initialize_parallel_zw_mode
lappend command_list PB_CMD_init_parallel_zw_mode
lappend command_list PB_CMD_initialize_tool_list
lappend command_list PB_CMD_init_tool_list
lappend command_list PB_CMD_init_tape_break
lappend command_list PB_CMD_initialize_spindle_axis
lappend command_list PB_CMD_init_spindle_axis
lappend command_list PB_CMD_initialize_helix
lappend command_list PB_CMD_init_helix
lappend command_list PB_CMD_pq_cutcom_initialize
lappend command_list PB_CMD_init_pq_cutcom

lappend command_list PB_CMD_kin_init_probing_cycles

lappend command_list PB_DEFINE_MACROS

if { [info exists mom_kin_machine_type] } {
if { [string match “3_axis_mill_turn” $mom_kin_machine_type] } {

     lappend command_list  PB_CMD_kin_init_mill_xzclappend command_list  PB_CMD_kin_mill_xzc_initlappend command_list  PB_CMD_kin_init_mill_turnlappend command_list  PB_CMD_kin_mill_turn_initialize}

}

foreach cmd $command_list {

  if { [CMD_EXIST "$cmd"] } {# <PB v2.0.2># Old init commands for XZC/MILL_TURN posts are not executed.# Parameters set by these commands in the v2.0 legacy posts# will need to be transfered to PB_CMD_init_mill_xzc &# PB_CMD_init_mill_turn commands respectively.switch $cmd {"PB_CMD_kin_mill_xzc_init" -"PB_CMD_kin_mill_turn_initialize" {}default { eval $cmd }}rename $cmd ""proc $cmd { args } {}}

}
}

#=============================================================
proc PB_CMD_negate_R_value { } {
#=============================================================

This command negates the value of radius when the included angle

of an arc is greater than 180.

==> This comamnd may be added to the Circular Move event for a post

of Fanuc controller when the R-style circular output format is used.

10-05-11 gsl - (pb801 IR2178985) Initial version

global mom_arc_angle mom_arc_radius

if [expr KaTeX parse error: Expected '}', got 'EOF' at end of input: …adius [expr -1*mom_arc_radius]
}
}

#=============================================================
proc PB_CMD_pause { } {
#=============================================================

This command enables you to pause the UG/Post processing.

PAUSE
}

#=============================================================
proc PB_CMD_reload_iks_parameters { } {
#=============================================================

This command overloads new IKS params from a machine model (NX4^).

It will be executed automatically at the start of each path

or when CSYS has changed.

==> Uncomment the “return” statement below to disable the reload.

return

global mom_csys_matrix
global mom_kin_iks_usage

#----------------------------------------------------------

Set a classification to fetch kinematic parameters from

a particular set of K-components of a machine.

- Default is NONE.

#----------------------------------------------------------
set custom_classification NONE

if { [info exists mom_kin_iks_usage] && $mom_kin_iks_usage == 1 } {
if { [info exists mom_csys_matrix] } {
if { [CMD_EXIST MOM_validate_machine_model] } {
if { ![string compare “TRUE” [MOM_validate_machine_model]] } {

           MOM_reload_iks_parameters "$custom_classification"#<06-20-2014 gsl> ir7155292 - Force machine's spindle axis to be {0,0,1} <== Not certain it's always true!# set ::mom_kin_spindle_axis(0) 0.0; set ::mom_kin_spindle_axis(1) 0.0; set ::mom_kin_spindle_axis(2) 1.0MOM_reload_kinematics}}}

}
}

#=============================================================
proc PB_CMD_restore_work_plane_change { } {
#=============================================================
#<02-18-08 gsl> Restore work plane change flag, if being disabled due to a simulated cycle.

global mom_user_work_plane_change mom_sys_work_plane_change
global mom_user_spindle_first spindle_first

if { [info exists mom_user_work_plane_change] } {
set mom_sys_work_plane_change $mom_user_work_plane_change
set spindle_first $mom_user_spindle_first
unset mom_user_work_plane_change
unset mom_user_spindle_first
}
}

#=============================================================
proc PB_CMD_revise_new_iks { } {
#=============================================================

This command is executed automatically, which allows you

to change the default IKS parameters or disable the IKS

service completely.

–> Do not attach this command to any event marker! ***

global mom_kin_iks_usage
global mom_kin_rotary_axis_method
global mom_kin_spindle_axis
global mom_kin_4th_axis_vector
global mom_kin_5th_axis_vector

Uncomment next statement to disable new IKS service

set mom_kin_iks_usage 0

Uncomment next statement to change rotary solution method

set mom_kin_rotary_axis_method “ZERO”

Reload kinematics if any parameter above has changed.

if { ([info exists mom_kin_iks_usage] && !$mom_kin_iks_usage) ||
([info exists mom_kin_rotary_axis_method] && [string match “ZERO” $mom_kin_rotary_axis_method]) } {

  MOM_reload_kinematics

}
}

#=============================================================
proc PB_CMD_run_postprocess { } {
#=============================================================

This is an example showing how MOM_run_postprocess can be used.

It can be called in the Start of Program event (or anywhere)

to process the same objects being posted with a secondary post.

==> It’s advisable NOT to use the active post and the same

output file for this secondary posting process.

==> Ensure legitimate and fully qualified post processor and

output file are specified with the command.

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

CAUTION - Uncomment next line to activate this function!

return
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

MOM_run_postprocess “[file dirname $::mom_event_handler_file_name]/MORI_HORI_Sub.tcl”
“[file dirname KaTeX parse error: Undefined control sequence: \ at position 50: …I_HORI_Sub.def"\̲ ̲ …{::mom_output_file_directory}sub_program.out”
}

#=============================================================
proc PB_CMD_set_csys { } {
#=============================================================

This custom command is provided as the default to nullify

the same command in a linked post that may have been

imported from pb_cmd_coordinate_system_rotation.tcl.

}

#=============================================================
proc PB_CMD_set_cycle_plane { } {
#=============================================================

Use this command to determine and output proper plane code

when G17/18/19 is used in the cycle definition.

<04-15-08 gsl> - Add initialization for protection

<03-06-08 gsl> - Declare needed global variables

<02-28-08 gsl> - Make use of mom_spindle_axis

<06-22-09 gsl> - Call PB_CMD_set_principal_axis

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

This option can be set to 1, if the address of cycle’s

principal axis needs to be suppressed. (Ex. Siemens controller)

#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
set suppress_principal_axis 0

#++++++++++++++++++++++++++++++++++++++++++++++++++++++

This option can be set to 1, if the plane code needs

to be forced out @ the start of every set of cycles.

#++++++++++++++++++++++++++++++++++++++++++++++++++++++
set force_plane_code 0

global mom_cycle_spindle_axis

PB_CMD_set_principal_axis

switch $mom_cycle_spindle_axis {
0 {
set principal_axis X
}
1 {
set principal_axis Y
}
2 {
set principal_axis Z
}
default {
set principal_axis “”
}
}

if { $suppress_principal_axis && [string length $principal_axis] > 0 } {
MOM_suppress once $principal_axis
}

if { $force_plane_code } {
global cycle_init_flag

  if { [info exists cycle_init_flag] && [string match "TRUE" $cycle_init_flag] } {MOM_force once G_plane}

}
}

#=============================================================
proc PB_CMD_set_principal_axis { } {
#=============================================================

This command can be used to determine the principal axis.

=> It can be used to determine a proper work plane when the

“Work Plane” parameter is not specified with an operation.

<06-22-09 gsl> - Extracted from PB_CMD_set_cycle_plane

<10-09-09 gsl> - Do not define mom_pos_arc_plane unless it doesn’t exist.

<03-10-10 gsl> - Respect tool axis for 3-axis & XZC cases

<01-21-11 gsl> - Enhance header description

<07-12-12 gsl> - Find principal axis for XZC-mill from the spindle axis

global mom_cycle_spindle_axis
global mom_spindle_axis
global mom_cutcom_plane mom_pos_arc_plane

Initialization spindle axis

global mom_kin_spindle_axis
global mom_sys_spindle_axis
if { ![info exists mom_kin_spindle_axis] } {
set mom_kin_spindle_axis(0) 0.0
set mom_kin_spindle_axis(1) 0.0
set mom_kin_spindle_axis(2) 1.0
}
if { ![info exists mom_sys_spindle_axis] } {
VMOV 3 mom_kin_spindle_axis mom_sys_spindle_axis
}
if { ![info exists mom_spindle_axis] } {
VMOV 3 mom_sys_spindle_axis mom_spindle_axis
}

Default cycle spindle axis to Z

set mom_cycle_spindle_axis 2

Respect tool axis only for 3-axis mill

global mom_kin_machine_type mom_tool_axis
if [string match “3_axis_mill” $mom_kin_machine_type] {
VMOV 3 mom_tool_axis spindle_axis
} else {
VMOV 3 mom_spindle_axis spindle_axis
}

if { [EQ_is_equal [expr abs($spindle_axis(0))] 1.0] } {
set mom_cycle_spindle_axis 0
}

if { [EQ_is_equal [expr abs($spindle_axis(1))] 1.0] } {
set mom_cycle_spindle_axis 1
}

switch $mom_cycle_spindle_axis {
0 {
set mom_cutcom_plane YZ
}
1 {
set mom_cutcom_plane ZX
}
2 {
set mom_cutcom_plane XY
}
default {
set mom_cutcom_plane UNDEFINED
}
}

Set arc plane when it’s not defined

if { ![info exists mom_pos_arc_plane] || $mom_pos_arc_plane == “” } {
set mom_pos_arc_plane $mom_cutcom_plane
}
}

#=============================================================
proc PB_CMD_start_of_alignment_character { } {
#=============================================================

This command can be used to output a special sequence number character.

Replace the “:” with any character that you require.

You must use the command “PB_CMD_end_of_alignment_character” to reset

the sequence number back to the original setting.

global mom_sys_leader saved_seq_num
set saved_seq_num $mom_sys_leader(N)
set mom_sys_leader(N) “:”
}

#=============================================================
proc PB_CMD_start_of_operation_force_addresses { } {
#=============================================================
MOM_force once S M_spindle X Y Z fourth_axis fifth_axis F
}

#=============================================================
proc PB_CMD_suppress_linear_block_plane_code { } {
#=============================================================

This command is to be called in the linear move event to suppress

G_plane address when the cutcom status has not changed.

– Assuming G_cutcom address is modal and G_plane exists in the block

#<10-11-09 gsl> - New
#<01-20-11 gsl> - Force out plane code for the 1st linear move when CUTCOM is on
#<03-16-12 gsl> - Added use of CALLED_BY

Restrict this command to be executed only by MOM_linear_move

if { ![CALLED_BY “MOM_linear_move”] } {
return
}

global mom_cutcom_status mom_user_prev_cutcom_status

if { ![info exists mom_cutcom_status] } {
set mom_cutcom_status UNDEFINED
}

if { ![info exists mom_user_prev_cutcom_status] } {
set mom_user_prev_cutcom_status UNDEFINED
}

Suppress plane code when no change of CUTCOM status

if { [string match “UNDEFINED” $mom_cutcom_status] ||
[string match $mom_user_prev_cutcom_status $mom_cutcom_status] } {

  MOM_suppress once G_plane

} else {

 # Force out plane code for the 1st CUTCOM activation of an operation,# otherwise plane code will only come out when work plane has changed# since last activation.#set force_1st_plane_code  "1"if { $force_1st_plane_code } {# This var should have been set in PB_first_linear_moveglobal mom_sys_first_linear_moveif { ![info exists mom_sys_first_linear_move] || $mom_sys_first_linear_move } {if { [string match "LEFT"  $mom_cutcom_status] ||\[string match "RIGHT" $mom_cutcom_status] ||\[string match "ON"    $mom_cutcom_status] } {MOM_force once G_planeset mom_sys_first_linear_move 0}}}

}

if { ![string match $mom_user_prev_cutcom_status $mom_cutcom_status] } {
set mom_user_prev_cutcom_status $mom_cutcom_status
}
}

#=============================================================
proc PB_CMD_tool_change_force_addresses { } {
#=============================================================
MOM_force once G_adjust H X Y Z S fourth_axis fifth_axis
}

#=============================================================
proc ARCTAN { y x } {
#=============================================================
global PI

if { [EQ_is_zero $y] } { set y 0 }
if { [EQ_is_zero $x] } { set x 0 }

if { [expr $y == 0] && [expr $x == 0] } {
return 0
}

set ang [expr atan2( y , y, y,x)]

if { $ang < 0 } {
return [expr $ang + $PI*2]
} else {
return $ang
}
}

#=============================================================
proc ARR_sort_array_to_list { ARR {by_value 0} } {
#=============================================================

This command will sort and build a list of elements of an array.

ARR : Array Name

by_value : 0 Sort elements by names (default)

1 Sort elements by values

Return a list of {name value} couplets

upvar $ARR arr

set list [list]
foreach { e v } [array get arr] {
lappend list “$e $v”
}

set val [lindex [lindex $list 0] $by_value]

if [string is integer “$val”] {
set list [lsort -integer -decreasing -index $by_value KaTeX parse error: Expected 'EOF', got '}' at position 10: list] }̲ elseif [string…val"] {
set list [lsort -real -decreasing -index $by_value $list]
} else {
set list [lsort -dictionary -decreasing -index $by_value $list]
}

return $list
}

#=============================================================
proc CALLED_BY { caller {out_warn 0} args } {
#=============================================================

This command can be used in the beginning of a command

to designate a specific caller for the command in question.

- Users can set the optional flag “out_warn” to “1” to output

warning message when a command is being called by a

non-designated caller. By default, warning message is suppressed.

Syntax:

if { ![CALLED_BY “cmd_string”] } { return ;# or do something }

or

if { ![CALLED_BY “cmd_string” 1] } { return ;# To output warning }

Revisions:

#-----------

05-25-10 gsl - Initial implementation

03-09-11 gsl - Enhanced description

if { ![string compare “$caller” [info level -2] ] } {
return 1
} else {
if { KaTeX parse error: Expected 'EOF', got '}' at position 10: out_warn }̲ { CAT…caller"!"
}
return 0
}
}

#=============================================================
proc CATCH_WARNING { msg {output 1} } {
#=============================================================

This command is called in a post to spice up the message to be output to the warning file.

global mom_warning_info
global mom_motion_event
global mom_event_number
global mom_motion_type
global mom_operation_name

if { $output == 1 } {

  set level [info level]set call_stack ""for { set i 1 } { $i < $level } { incr i } {set call_stack "$call_stack\[ [lindex [info level $i] 0] \]"}global mom_o_bufferif { ![info exists mom_o_buffer] } {set mom_o_buffer ""}if { ![info exists mom_motion_event] } {set mom_motion_event ""}if { [info exists mom_operation_name] && [string length $mom_operation_name] } {set mom_warning_info "$msg\n\  Operation $mom_operation_name - Event $mom_event_number [MOM_ask_event_type] :\$mom_motion_event ($mom_motion_type)\n\    $mom_o_buffer\n\      $call_stack"} else {set mom_warning_info "$msg\n\  Event $mom_event_number [MOM_ask_event_type] :\$mom_motion_event ($mom_motion_type)\n\    $mom_o_buffer\n\      $call_stack"}MOM_catch_warning

}

Restore mom_warning_info for subsequent use

set mom_warning_info $msg
}

#=============================================================
proc CMD_EXIST { cmd {out_warn 0} args } {
#=============================================================

This command can be used to detect the existence of a command

before executing it.

- Users can set the optional flag “out_warn” to “1” to output

warning message when a command to be called doesn’t exist.

By default, warning message is suppressed.

Syntax:

if { [CMD_EXIST “cmd_string”] } { cmd_string }

or

if { [CMD_EXIST “cmd_string” 1] } { cmd_string ;# To output warning }

Revisions:

#-----------

05-25-10 gsl - Initial implementation

03-09-11 gsl - Enhanced description

if { [llength [info commands “$cmd”] ] } {
return 1
} else {
if { KaTeX parse error: Expected 'EOF', got '}' at position 10: out_warn }̲ { CAT…cmd" called by “[info level -1]” does not exist!"
}
return 0
}
}

#=============================================================
proc EXEC { command_string {__wait 1} } {
#=============================================================

This command can be used in place of the intrinsic Tcl “exec” command

of which some problems have been reported under Win64 O/S and multi-core

processors environment.

Input:

command_string – command string

__wait – optional flag

1 (default) = Caller will wait until execution is complete.

0 (specified) = Caller will not wait.

Return:

Results of execution

Revisions:

#-----------

05-19-10 gsl - Initial implementation

global tcl_platform

if { $__wait } {

  if { [string match "windows" $tcl_platform(platform)] } {global env mom_logname# Create a temporary file to collect outputset result_file "$env(TEMP)/${mom_logname}__EXEC_[clock clicks].out"# Clean up existing fileregsub -all {\\} $result_file {/}  result_file#regsub -all { }  $result_file {\ } result_fileif { [file exists "$result_file"] } {file delete -force "$result_file"}#<11-05-2013> Escape spacesset cmd [concat exec $command_string > \"$result_file\"]regsub -all {\\} $cmd {\\\\} cmdregsub -all { }  $result_file {\\\ } result_fileeval $cmd# Return results & clean up temporary fileif { [file exists "$result_file"] } {set fid [open "$result_file" r]set result [read $fid]close $fidfile delete -force "$result_file"return $result}} else {set cmd [concat exec $command_string]return [eval $cmd]}

} else {

  if { [string match "windows" $tcl_platform(platform)] } {set cmd [concat exec $command_string &]regsub -all {\\} $cmd {\\\\} cmdreturn [eval $cmd]} else {return [exec $command_string &]}

}
}

#=============================================================
proc INFO { args } {
#=============================================================
MOM_output_to_listing_device [join $args]
}

#=============================================================
proc LIMIT_ANGLE { a } {
#=============================================================
set a [expr fmod( a , 360 ) ] s e t a [ e x p r ( a,360)] set a [expr ( a,360)]seta[expr(a < 0) ? ($a + 360) : $a]

return $a
}

#=============================================================
proc MAXMIN_ANGLE { a max min {tol_flag 0} } {
#=============================================================
if { $tol_flag == 0 } { ;# Direct comparison

  while { $a < $min } { set a [expr $a + 360.0] }while { $a > $max } { set a [expr $a - 360.0] }

} else { ;# Tolerant comparison

  while { [EQ_is_lt $a $min] } { set a [expr $a + 360.0] }while { [EQ_is_gt $a $max] } { set a [expr $a - 360.0] }

}

return $a
}

#=============================================================
proc OPERATOR_MSG { msg {seq_no 0} } {
#=============================================================
foreach s [split KaTeX parse error: Undefined control sequence: \n at position 5: msg \̲n̲] { if { …seq_no } {
MOM_output_text “$::mom_sys_control_out $s KaTeX parse error: Expected 'EOF', got '}' at position 29: …trol_in" }̲ else { …::mom_sys_control_out $s $::mom_sys_control_in”
}
}

set ::mom_o_buffer “”
}

#=============================================================
proc PAUSE { args } {
#=============================================================

Revisions:

#-----------

05-19-10 gsl - Use EXEC command

global env

if { [info exists env(PB_SUPPRESS_UGPOST_DEBUG)] && $env(PB_SUPPRESS_UGPOST_DEBUG) == 1 } {
return
}

global gPB

if { [info exists gPB(PB_disable_MOM_pause)] && $gPB(PB_disable_MOM_pause) == 1 } {
return
}

global tcl_platform

set cam_aux_dir [MOM_ask_env_var UGII_CAM_AUXILIARY_DIR]

if { [string match “windows” $tcl_platform(platform)] } {
set ug_wish “ugwish.exe”
} else {
set ug_wish ugwish
}

if { [file exists c a m a u x d i r {cam_aux_dir} cama​uxd​irug_wish] && [file exists ${cam_aux_dir}mom_pause.tcl] } {

  set title ""set msg ""if { [llength $args] == 1 } {set msg [lindex $args 0]}if { [llength $args] > 1 } {set title [lindex $args 0]set msg [lindex $args 1]}set command_string [concat \"${cam_aux_dir}$ug_wish\" \"${cam_aux_dir}mom_pause.tcl\" \"$title\" \"$msg\"]set res [EXEC $command_string]switch [string trim $res] {no {set gPB(PB_disable_MOM_pause) 1}cancel {set gPB(PB_disable_MOM_pause) 1uplevel #0 {MOM_abort "*** User Abort Post Processing *** "}}default {return}}

} else {

  CATCH_WARNING "PAUSE not executed -- \"$ug_wish\" or \"mom_pause.tcl\" not found"

}
}

#=============================================================
proc PAUSE_win64 { args } {
#=============================================================
global env
if { [info exists env(PB_SUPPRESS_UGPOST_DEBUG)] && $env(PB_SUPPRESS_UGPOST_DEBUG) == 1 } {
return
}

global gPB
if { [info exists gPB(PB_disable_MOM_pause)] && $gPB(PB_disable_MOM_pause) == 1 } {
return
}

set cam_aux_dir [MOM_ask_env_var UGII_CAM_AUXILIARY_DIR]
set ug_wish “ugwish.exe”

if { [file exists c a m a u x d i r {cam_aux_dir} cama​uxd​irug_wish] &&
[file exists ${cam_aux_dir}mom_pause_win64.tcl] } {

  set title ""set msg ""if { [llength $args] == 1 } {set msg [lindex $args 0]}if { [llength $args] > 1 } {set title [lindex $args 0]set msg [lindex $args 1]}####### Define a scratch file and pass it to mom_pause_win64.tcl script -##   A separated process will be created to construct the Tk dialog.#   This process will communicate with the main process via the state of a scratch file.#   This scratch file will collect the messages that need to be conveyed from the#   child process to the main process.######global mom_lognameset pause_file_name "$env(TEMP)/${mom_logname}_mom_pause_[clock clicks].txt"####### Path names should be per unix style for "open" command######regsub -all {\\} $pause_file_name {/}  pause_file_nameregsub -all { }  $pause_file_name {\ } pause_file_nameregsub -all {\\} $cam_aux_dir {/}  cam_aux_dirregsub -all { }  $cam_aux_dir {\ } cam_aux_dirif [file exists $pause_file_name] {file delete -force $pause_file_name}####### Note that the argument order for mom_pasue.tcl has been changed# The assumption at this point is we will always have the communication file as the first# argument and optionally the title and message as the second and third arguments######open "|${cam_aux_dir}$ug_wish ${cam_aux_dir}mom_pause_win64.tcl ${pause_file_name} {$title} {$msg}"####### Waiting for the mom_pause to complete its process...# - This is indicated when the scratch file materialized and became read-only.######while { ![file exists $pause_file_name] || [file writable $pause_file_name] } { }####### Delay a 100 milli-seconds to ensure that sufficient time is given for the other process to complete.######after 100####### Open the scratch file to read and process the information.  Close it afterward.######set fid [open "$pause_file_name" r]set res [string trim [gets $fid]]switch $res {no {set gPB(PB_disable_MOM_pause) 1}cancel {close $fidfile delete -force $pause_file_nameset gPB(PB_disable_MOM_pause) 1uplevel #0 {MOM_abort "*** User Abort Post Processing *** "}}default {}}####### Delete the scratch file######close $fidfile delete -force $pause_file_name

}
}

#=============================================================
proc PAUSE_x { args } {
#=============================================================
global env
if { [info exists env(PB_SUPPRESS_UGPOST_DEBUG)] && $env(PB_SUPPRESS_UGPOST_DEBUG) == 1 } {
return
}

global gPB
if { [info exists gPB(PB_disable_MOM_pause)] && $gPB(PB_disable_MOM_pause) == 1 } {
return
}

#==========

Win64 OS

global tcl_platform

if { [string match “windows” $tcl_platform(platform)] } {
global mom_sys_processor_archit

  if { ![info exists mom_sys_processor_archit] } {set pVal ""set env_vars [array get env]set idx [lsearch $env_vars "PROCESSOR_ARCHITE*"]if { $idx >= 0 } {set pVar [lindex $env_vars $idx]set pVal [lindex $env_vars [expr $idx + 1]]}set mom_sys_processor_archit $pVal}if { [string match "*64*" $mom_sys_processor_archit] } {PAUSE_win64 $args

return
}
}

set cam_aux_dir [MOM_ask_env_var UGII_CAM_AUXILIARY_DIR]

if { [string match “windows” $tcl_platform(platform)] } {
set ug_wish “ugwish.exe”
} else {
set ug_wish ugwish
}

if { [file exists c a m a u x d i r {cam_aux_dir} cama​uxd​irug_wish] && [file exists ${cam_aux_dir}mom_pause.tcl] } {

  set title ""set msg ""if { [llength $args] == 1 } {set msg [lindex $args 0]}if { [llength $args] > 1 } {set title [lindex $args 0]set msg [lindex $args 1]}set res [exec ${cam_aux_dir}$ug_wish ${cam_aux_dir}mom_pause.tcl $title $msg]switch $res {no {set gPB(PB_disable_MOM_pause) 1}cancel {set gPB(PB_disable_MOM_pause) 1uplevel #0 {MOM_abort "*** User Abort Post Processing *** "}}default { return }}

}
}

#=============================================================
proc STR_MATCH { VAR str {out_warn 0} } {
#=============================================================

This command will match a variable with a given string.

- Users can set the optional flag “out_warn” to “1” to produce

warning message when the variable is not defined in the scope

of the caller of this function.

upvar $VAR var

if { [info exists var] && [string match “ v a r " " var" " var""str”] } {
return 1
} else {
if { $out_warn } {
CATCH_WARNING “Variable $VAR is not defined in “[info level -1]”!”
}
return 0
}
}

#=============================================================
proc TRACE { {up_level 0} } {
#=============================================================

up_level to be a negative integer

set start_idx 1

set str “”
set level [expr [info level] - int(abs($up_level))]
for { set i $start_idx } { $i <= $level } { incr i } {
if { $i < KaTeX parse error: Expected 'EOF', got '}' at position 7: level }̲ { set…{str}[lindex [info level KaTeX parse error: Undefined control sequence: \n at position 6: i] 0]\̲n̲" } else …{str}[lindex [info level $i] 0]"
}
}

return $str
}

#=============================================================
proc UNSET_VARS { args } {
#=============================================================

Inputs: List of variable names

if { [llength $args] == 0 } {
return
}

foreach VAR $args {
upvar $VAR var

  global tcl_versionif { [array exists var] } {if { [expr $tcl_version < 8.4] } {foreach a [array names var] {if { [info exists var($a)] } {unset var($a)}}unset var} else {array unset var}}if { [info exists var] } {unset var}

}
}

#=============================================================
proc VMOV { n p1 p2 } {
#=============================================================
upvar $p1 v1 ; upvar $p2 v2

for { set i 0 } { $i < KaTeX parse error: Expected 'EOF', got '}' at position 3: n }̲ { incr i } { …i) v 1 ( v1( v1(i)
}
}

#=============================================================
proc WORKPLANE_SET { } {
#=============================================================
global mom_cycle_spindle_axis
global mom_sys_spindle_axis
global traverse_axis1 traverse_axis2

if { ![info exists mom_sys_spindle_axis] } {
set mom_sys_spindle_axis(0) 0.0
set mom_sys_spindle_axis(1) 0.0
set mom_sys_spindle_axis(2) 1.0
}

if { ![info exists mom_cycle_spindle_axis] } {
set x $mom_sys_spindle_axis(0)
set y $mom_sys_spindle_axis(1)
set z $mom_sys_spindle_axis(2)

  if { [EQ_is_zero $y] && [EQ_is_zero $z] } {set mom_cycle_spindle_axis 0} elseif { [EQ_is_zero $x] && [EQ_is_zero $z] } {set mom_cycle_spindle_axis 1} else {set mom_cycle_spindle_axis 2}

}

if { $mom_cycle_spindle_axis == 2 } {
set traverse_axis1 0 ; set traverse_axis2 1
} elseif { $mom_cycle_spindle_axis == 0 } {
set traverse_axis1 1 ; set traverse_axis2 2
} elseif { $mom_cycle_spindle_axis == 1 } {
set traverse_axis1 0 ; set traverse_axis2 2
}
}

#=============================================================
proc PB_load_alternate_unit_settings { } {
#=============================================================
global mom_output_unit mom_kin_output_unit

Skip this function when output unit agrees with post unit.

if { ![info exists mom_output_unit] } {
set mom_output_unit $mom_kin_output_unit
return
} elseif { ![string compare $mom_output_unit $mom_kin_output_unit] } {
return
}

global mom_event_handler_file_name

Set unit conversion factor

if { ![string compare $mom_output_unit “MM”] } {
set factor 25.4
} else {
set factor [expr 1/25.4]
}

Define unit dependent variables list

set unit_depen_var_list [list mom_kin_x_axis_limit mom_kin_y_axis_limit mom_kin_z_axis_limit
mom_kin_pivot_gauge_offset mom_kin_ind_to_dependent_head_x
mom_kin_ind_to_dependent_head_z]

set unit_depen_arr_list [list mom_kin_4th_axis_center_offset
mom_kin_5th_axis_center_offset
mom_kin_machine_zero_offset
mom_kin_4th_axis_point
mom_kin_5th_axis_point
mom_sys_home_pos]

Load unit dependent variables

foreach var $unit_depen_var_list {
if { ![info exists $var] } {
global $var
}
if { [info exists $var] } {
set $var [expr [set $var] * $factor]
MOM_reload_variable $var
}
}

foreach var $unit_depen_arr_list {
if { ![info exists $var] } {
global $var
}
foreach item [array names $var] {
if { [info exists v a r ( {var}( var(item)] } {
set v a r ( {var}( var(item) [expr [set v a r ( {var}( var(item)] * $factor]
}
}

  MOM_reload_variable -a $var

}

Source alternate unit post fragment

uplevel #0 {
global mom_sys_alt_unit_post_name
set alter_unit_post_name
“[file join [file dirname $mom_event_handler_file_name] [file rootname $mom_sys_alt_unit_post_name]].tcl”

  if { [file exists $alter_unit_post_name] } {source "$alter_unit_post_name"}unset alter_unit_post_name

}

if { [llength [info commands PB_load_address_redefinition]] > 0 } {
PB_load_address_redefinition
}

MOM_reload_kinematics
}

if [info exists mom_sys_start_of_program_flag] {
if [llength [info commands PB_CMD_kin_start_of_program] ] {
PB_CMD_kin_start_of_program
}
} else {
set mom_sys_head_change_init_program 1
set mom_sys_start_of_program_flag 1
}

这里写自定义目录标题

  • b.tcl - 3_axis_mill
  • 这是 3 轴铣床。
  • Created by dp @ Wednesday, November 06, 2019 8:52:33 AM China Standard Time
  • with Post Builder version 10.0.3.
  • Dummy command to log changes in this post --
  • 15-Jul-2014 gsl - Initial version
    • Listing File variables
  • This command is executed just before every NC block is
  • to be output to a file.
  • - Never overload this command!
  • - Any customization should be done in PB_CMD_before_output!
  • Load parameters for alternate output units
  • Override spindle axis vector defined in PB_CMD_init_rotary
  • Unitize vectors
  • Reload kinematics
  • Post Builder provided format for the current mode:
  • For simple mill-turn
  • Redefine FEEDRATE_SET
  • Accumulated time should be in minutes.
  • First tool only gets handled once
  • Set this variable to signal 1st linear move has been handled.
  • This custom command is called by FEEDRATE_SET;
  • it allows you to modify the feed rate number after being
  • calculated by the system.
  • Use global frn factor (defined as 1.0 in ugpost_base.tcl) or
  • define a custom one here
  • set mom_sys_frn_factor 1.0
  • Default handler for UDE MOM_insert
  • - Do not attach it to any event!
  • This procedure is executed when the Insert command is activated.
  • Default handler for UDE MOM_operator_message
  • - Do not attach it to any event!
  • This procedure is executed when the Operator Message command is activated.
  • Default handler for UDE MOM_opskip_off
  • - Do not attach it to any event!
  • This procedure is executed when the Optional skip command is activated.
  • Default handler for UDE MOM_opskip_on
  • - Do not attach it to any event!
  • This procedure is executed when the Optional skip command is activated.
  • Default handler for UDE MOM_pprint
  • - Do not attach it to any event!
  • This procedure is executed when the PPrint command is activated.
  • Default handler for UDE MOM_text
  • - Do not attach it to any event!
  • This procedure is executed when the Text command is activated.

欢迎使用Markdown编辑器

你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。

新的改变

我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客:

  1. 全新的界面设计 ,将会带来全新的写作体验;
  2. 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样式 进行展示;
  3. 增加了 图片拖拽 功能,你可以将本地的图片直接拖拽到编辑区域直接展示;
  4. 全新的 KaTeX数学公式 语法;
  5. 增加了支持甘特图的mermaid语法1 功能;
  6. 增加了 多屏幕编辑 Markdown文章功能;
  7. 增加了 焦点写作模式、预览模式、简洁写作模式、左右区域同步滚轮设置 等功能,功能按钮位于编辑区域与预览区域中间;
  8. 增加了 检查列表 功能。

功能快捷键

撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
查找:Ctrl/Command + F
替换:Ctrl/Command + G

合理的创建标题,有助于目录的生成

直接输入1次#,并按下space后,将生成1级标题。
输入2次#,并按下space后,将生成2级标题。
以此类推,我们支持6级标题。有助于使用TOC语法后生成一个完美的目录。

如何改变文本的样式

强调文本 强调文本

加粗文本 加粗文本

标记文本

删除文本

引用文本

H2O is是液体。

210 运算结果是 1024.

插入链接与图片

链接: link.

图片:

带尺寸的图片:

居中的图片:

居中并且带尺寸的图片:

当然,我们为了让用户更加便捷,我们增加了图片拖拽功能。

如何插入一段漂亮的代码片

去博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片.

// An highlighted block
var foo = 'bar';

生成一个适合你的列表

  • 项目

    • 项目

      • 项目
  1. 项目1
  2. 项目2
  3. 项目3
  • 计划任务
  • 完成任务

创建一个表格

一个简单的表格是这么创建的:

项目 Value
电脑 $1600
手机 $12
导管 $1

设定内容居中、居左、居右

使用:---------:居中
使用:----------居左
使用----------:居右

第一列 第二列 第三列
第一列文本居中 第二列文本居右 第三列文本居左

SmartyPants

SmartyPants将ASCII标点字符转换为“智能”印刷标点HTML实体。例如:

TYPE ASCII HTML
Single backticks 'Isn't this fun?' ‘Isn’t this fun?’
Quotes "Isn't this fun?" “Isn’t this fun?”
Dashes -- is en-dash, --- is em-dash – is en-dash, — is em-dash

创建一个自定义列表

Markdown
Text-to- HTML conversion tool
Authors
John
Luke

如何创建一个注脚

一个具有注脚的文本。2

注释也是必不可少的

Markdown将文本转换为 HTML

KaTeX数学公式

您可以使用渲染LaTeX数学表达式 KaTeX:

Gamma公式展示 Γ ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N Γ(n)=(n−1)!∀n∈N 是通过欧拉积分

Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. Γ(z)=∫0∞​tz−1e−tdt.

你可以找到更多关于的信息 LaTeX 数学表达式here.

新的甘特图功能,丰富你的文章

Mon 06 Mon 13 Mon 20 已完成 进行中 计划一 计划二 现有任务 Adding GANTT diagram functionality to mermaid
  • 关于 甘特图 语法,参考 这儿,

UML 图表

可以使用UML图表进行渲染。 Mermaid. 例如下面产生的一个序列图:

张三 李四 王五 你好!李四, 最近怎么样? 你最近怎么样,王五? 我很好,谢谢! 我很好,谢谢! 李四想了很长时间, 文字太长了 不适合放在一行. 打量着王五... 很好... 王五, 你怎么样? 张三 李四 王五

这将产生一个流程图。:

链接
长方形
圆角长方形
菱形
  • 关于 Mermaid 语法,参考 这儿,

FLowchart流程图

我们依旧会支持flowchart的流程图:

Created with Raphaël 2.2.0 开始 我的操作 确认? 结束 yes no
  • 关于 Flowchart流程图 语法,参考 这儿.

导出与导入

导出

如果你想尝试使用此编辑器, 你可以在此篇文章任意编辑。当你完成了一篇文章的写作, 在上方工具栏找到 文章导出 ,生成一个.md文件或者.html文件进行本地保存。

导入

如果你想加载一篇你写过的.md文件,在上方工具栏可以选择导入功能进行对应扩展名的文件导入,
继续你的创作。


  1. mermaid语法说明 ↩︎

  2. 注脚的解释 ↩︎

ugpost_tcl文件相关推荐

  1. MiniGUI开发指南

    MiniGUI 目录 MiniGUI 体系结构 概览 引言 POSIX线程 基于PThread的微客户/服务器结构 多线程通讯的关键数据结构--消息队列 面向对象技术在MiniGUI中的应用 未来考虑 ...

  2. golang通过RSA算法生成token,go从配置文件中注入密钥文件,go从文件中读取密钥文件,go RSA算法下token生成与解析;go java token共用

    RSA算法 token生成与解析 本文演示两种方式,一种是把密钥文件放在配置文件中,一种是把密钥文件本身放入项目或者容器中. 下面两种的区别在于私钥公钥的初始化, init方法,需要哪种取哪种. 通过 ...

  3. /var/lib/docker/overlay2/xxxxx no such file or directory docker文件删除引发的问题

    记一次误删引发的服务雪崩 K8s node节点磁盘报警,报警后我找到服务中占用磁盘最多的地方,在overlay2目录下,对下面的文件进行了删除   删除后,有状态服务先出现了问题,服务无法启动.停止. ...

  4. Access to XMLHttpRequest at file from origin ‘null‘ has been blocked by CORS policy谷歌浏览器本地打开项目js文件报错

    Access to XMLHttpRequest at 'file:///xxxxx/PQ.BaseInfo.proto' from origin 'null' has been blocked by ...

  5. 过滤Linux下不同大小的文件,linux查找当前目录下 M/G 大小的文件,删除Linux下指定大小的文件

    过滤Linux下不同大小的文件,linux查找当前目录下 M/G 大小的文件,删除Linux下指定大小的文件 find ./ -type f -size +1G| xargs rm 在清理系统日志文件 ...

  6. zip压缩多个文件,解压时不包含目录层级

    假设我们有个目录叫 dev,dev中有很多文件,我们想要将dev中的文件打包,名字可能叫dev.zip,但当我们解压的时候,不想要解压生成一个dev目录,想要直接解压在当前目录,这样如何压缩呢? # ...

  7. Linux下创建硬链接,文件访问为空,提示:xxxx: 符号连接的层数过多

    Linux下创建软链接|硬链接,文件访问为空,提示:x x x: 符号连接的层数过多. 原因:创建符号链接的时候未使用绝对路径,无论是源文件路径还是目标路径,都需要使用绝对路径. 如: ln -s / ...

  8. springboot设置文件上传大小(tomcat默认1M)

    application.yml # 设置文件上传大小(tomcat默认1M) server:tomcat:max-http-form-post-size: -1 spring:servlet:mult ...

  9. 将文件上传至ftp服务器,FTP文件上传工具类,将文件上传至服务器指定目录

    将文件上传至ftp服务器,传入File对象,将文件上传至ftp服务器 需要配置修改的点: 1. 服务器ip端口(服务器ip 端口22/21). 2. 服务器账号密码(服务器登录用户名密码). 3. 上 ...

最新文章

  1. TVM优化GPU机器翻译
  2. Docker系列 八.Docker下 Mysql 启动慢查询日志
  3. 安卓setclicklistener函数没有_金主脚本按键精灵安卓按键初体验—乱斗西游2自动签到...
  4. Qt Creator将应用程序部署到Android设备
  5. 运行Python程序的2种方式
  6. oracle 11gdata guard,Oracle 11g Data Guard配置
  7. Java BigInteger类| bitCount()方法与示例
  8. linux下的各个语言中stdin,stdout和stderr理解
  9. Unity3d 通过协程来实现文件的全部加载后执行
  10. 算法学习_简单递归算法
  11. XML转换JSON格式
  12. learning_git_from_Liao
  13. 失眠的岁月,我们都交了哪些科技智商税?
  14. cc美团_项目注册界面实现
  15. Windows内核安全与驱动编程学习笔记----1.WDK安装
  16. redis的基本操作And数据持久化方式以及redis实现mybatis缓存
  17. 基于GIS+AI、GIS+AR、GIS+三维的智慧城管综合应用平台
  18. python学习之 re库 正则表达式
  19. 真正解决layer弹层遮罩挡住窗体的问题
  20. 资料:《新概念英语》旧版(第四册)原文及全文翻译

热门文章

  1. avcodec_receive_frame 和 avcodec_send_packet的调用顺序
  2. 解决Oracle连接超时的方案(菜鸟简述)
  3. 2019,新的一年。
  4. 【游戏逆向】检测加速辅助案例分析
  5. 国家职称计算机中级考试报名时间,中级职称计算机考试_报名时间_考试内容_科目_题库_教材_爱考学...
  6. 语音输入法出了这么多年我几乎没用过,直到……
  7. 使用JS将GPRMC转换成WGS84/GCJ02
  8. 关于不同版本aee db文件的抓取
  9. windows的虚拟磁盘(vhd,vhdx)使用
  10. VS2017写C++时报错 表达式必须包含指向对象的指针类型