set cam_debug_dir [MOM_ask_env_var UGII_CAM_DEBUG_DIR]
source ${cam_debug_dir}mom_review.tcl
}
#### 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_output_transition_path "0"
set mom_sys_post_output_subprogram_enabled "0"
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!
#
# Write output buffer to the listing file with warnings
global mom_sys_list_output
if { [string match "ON" $mom_sys_list_output] } {
LIST_FILE
} else {
global tape_bytes mom_o_buffer
if { ![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 ")"
set mom_sys_use_default_unit_fragment "ON"
set mom_sys_alt_unit_post_name "db__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_advanced_turbo_output "0"
set mom_sys_tool_number_max "32"
set mom_sys_tool_number_min "1"
set mom_sys_post_description "这是 3 轴铣床。"
set mom_sys_word_separator " "
set mom_sys_end_of_block ""
set mom_sys_ugpadvkins_used "0"
set mom_sys_post_builder_version "(Final Release)"
####### 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 "2500"
set mom_kin_max_frn "1000"
set mom_kin_min_arc_length "0.20"
set mom_kin_min_arc_radius "0.002"
set mom_kin_min_dpm "0.0"
set mom_kin_min_fpm "0.1"
set mom_kin_min_fpr "0.1"
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 "1200"
set mom_kin_y_axis_limit "1200"
set mom_kin_z_axis_limit "1200"
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 UNDEFINED
#=============================================================
proc MOM_end_of_program { } {
#=============================================================
global mom_program_aborted mom_event_error
MOM_do_template end_of_program
MOM_set_seq_off
MOM_do_template rewind_stop_code
# Write tool list with time in commentary data
LIST_FILE_TRAILER
# Close warning and listing files
CLOSE_files
if [CMD_EXIST 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) $mom_kin_spindle_axis($i)
}
VEC3_unitize vec mom_kin_spindle_axis
foreach i { 0 1 2 } {
set vec($i) $mom_kin_4th_axis_vector($i)
}
VEC3_unitize vec mom_kin_4th_axis_vector
foreach i { 0 1 2 } {
set vec($i) $mom_kin_5th_axis_vector($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 $mom_sys_delay_param(${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
#=============================================================
proc MOM_clamp { } {
#=============================================================
global mom_clamp_axis
global mom_clamp_status
global mom_clamp_text
}
#=============================================================
proc MOM_cycle_plane_change { } {
#=============================================================
global cycle_init_flag
global mom_cycle_tool_axis_change
global mom_cycle_clearance_plane_change
#=============================================================
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
ABORT_EVENT_CHECK
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
ABORT_EVENT_CHECK
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
ABORT_EVENT_CHECK
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
ABORT_EVENT_CHECK
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
ABORT_EVENT_CHECK
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
if { ![info exists mom_sys_add_cutting_time] } {
set mom_sys_add_cutting_time 0.0
}
if { ![info exists mom_sys_add_non_cutting_time] } {
set mom_sys_add_non_cutting_time 0.0
}
# 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 [CMD_EXIST PB_CMD_kin_end_of_path] {
PB_CMD_kin_end_of_path
}
global mom_sys_in_operation
set mom_sys_in_operation 0
}
global mom_warning_info
set 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_origin { } {
#=============================================================
global mom_X
global mom_Y
global mom_Z
global mom_origin_text
}
#=============================================================
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
ABORT_EVENT_CHECK
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 "$mom_sys_control_out"
set ci "$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_y
PB_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_xz
PB_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_z
PB_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_xy
PB_SET_RAPID_MOD $rapid_traverse_mod $rapid_traverse_xy_blk aa mod_traverse
} else {
set traverse_block ""
}
}
default {
set spindle_block rapid_spindle
set traverse_block rapid_traverse
PB_SET_RAPID_MOD $rapid_spindle_mod $rapid_spindle_blk aa mod_spindle
PB_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 $spindle_block
} else {
MOM_output_literal "$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 $traverse_block
} else {
MOM_output_literal "$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 $traverse_block
} else {
MOM_output_literal "$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 $spindle_block
} else {
MOM_output_literal "$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
}
global mom_warning_info
set 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_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_info
set 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
}
MOM_force Once G_cutcom G_plane G_mode
MOM_do_template absolute_mode
PB_CMD_fix_RAPID_SET
if [CMD_EXIST 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 PB generated 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 PB generated handler for UDE MOM_operator_message
# - Do not attach it to any event!
#
# This procedure is executed when the Operator Message command is activated.
#
# 28-Apr-2017 ugs - Of pb1102mp
#
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
# 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 postprocessing
if { ![info exists mom_post_in_simulation] || $mom_post_in_simulation == 0 } {
MOM_output_literal $text_string
}
# Resume output to PTP
if { [string match "ON" $mom_sys_ptp_output] } {
MOM_open_output_file $ptp_file_name
}
set mom_operator_message_status $mom_operator_message
}
}
#=============================================================
proc PB_CMD_MOM_opskip_off { } {
#=============================================================
# Default PB generated handler for UDE MOM_opskip_off
# - Do not attach it to any event!
#
# This procedure is executed when the Optional skip command is activated.
#
MOM_set_line_leader off $::mom_sys_opskip_block_leader
set ::mom_sys_opskip_on 0
}
#=============================================================
proc PB_CMD_MOM_opskip_on { } {
#=============================================================
# Default PB generated handler for UDE MOM_opskip_on
# - Do not attach it to any event!
#
# <Note> Current MOM/Post implementation only handles opskip string appearing at the start of a block;
# and by default, it only supports one level of opskip control.
#
# This procedure is executed when the Optional skip command is activated.
#
MOM_set_line_leader always $::mom_sys_opskip_block_leader
set ::mom_sys_opskip_on 1
}
#=============================================================
proc PB_CMD_MOM_pprint { } {
#=============================================================
# Default PB generated 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 PB generated 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 $mom_record_text
MOM_operator_message
}
default
{
if {[info exists mom_user_defined_text]} {
MOM_output_literal "${mom_sys_control_out}${mom_user_defined_text}${mom_sys_control_in}"
}
}
}
}
#=============================================================
proc PB_CMD__config_post_options { } {
#=============================================================
# <PB v10.03>
# 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
# <PB v10.03>
# - 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__handle_end_of_subop_path { } {
#=============================================================
# 10/31/2018 gsl - This command can be called by MOM_end_of_subop_path handler.
#
global mom_move_type
global mom_move_type_name ;# <-- not reliable!
global mom_RTCP ;# ON/OFF
set subop [GET_SUBOP_MOVE_NAME $::mom_move_type]
# OPERATOR_MSG ">>> End of subop >$subop< $::mom_move_type"
switch "$subop" {
"Tool_Change_Container" {
# Remove info of tool change position when done.
UNSET_VARS ::mom_sys_interop_tool_change_pos
}
"Tool_Change_Position" {
# Save tool change position info
if { $::mom_interop_has_tool_change_container } {
VMOV 5 ::mom_pos ::mom_sys_interop_tool_change_pos
}
}
"Rotary_Tool_Center_Point_On" {
}
"Rotary_Tool_Center_Point_Off" {
}
"Move_to_Machine_Position" {
}
"Rotary_Point_Vector_Move" {
}
default {
}
}
}
#=============================================================
proc PB_CMD__handle_start_of_subop_path { } {
#=============================================================
# 10/31/2018 gsl - This command can be called by MOM_start_of_subop_path handler.
#
global mom_move_type
global mom_move_type_name
global mom_RTCP ;# ON/OFF
global mom_tool_change_status
set subop [GET_SUBOP_MOVE_NAME $::mom_move_type]
# OPERATOR_MSG ">>> Start of subop >$subop< $::mom_move_type"
#=============================================================
proc PB_CMD__interop_init_vars { } {
#=============================================================
# 31-Aug-2018 gsl - This command can be used to initialize some variables
# referenced while handling interOp GMC subops.
#
INIT_VAR ::mom_interop_has_tool_change_container
INIT_VAR ::mom_interop_has_tool_change_position
INIT_VAR ::mom_interop_has_tool_change
}
#=============================================================
proc PB_CMD__interop_is_transition_path { } {
#=============================================================
# 10/31/2018 gsl - This command can be used to identify an interOp operation.
#
if { $::mom_operation_type_enum == 900 } {
return 1
} else {
return 0
}
}
#=============================================================
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__suppress_probe_bore_clearance_retract { } {
#=============================================================
# - For Probing Operation -
#
# By default, NX/Post generates protected moves to enter and retract from
# the bore feature of a probing cycle when the radial clearance is zero.
#
# ==> This command can be attached to the "Start of Program" event
# to suppress the retract motion of the protected move.
#
# 19-Mar-2019 gsl - New
#
set ::mom_sys_suppress_probe_bore_clearance_retract 1
}
#=============================================================
proc PB_CMD_abort_event { } {
#=============================================================
# This command is automatically called by every motion event
# to abort its handler based on the flag set by other events
# 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 (non-zero) 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
if { [info exists ::mom_sys_abort_next_event] } {
switch $::mom_sys_abort_next_event {
2 -
3 {
# User may choose to abort NX/Post
set __abort_post 0
if { $__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
}
#=============================================================
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_cancel_suppress_force_once_per_event { } {
#=============================================================
# This command can be called to cancel the effect of
# "MOM_force Once" & "MOM_suppress Once" for each event.
#
# => It's to keep the effect of force & suppress once within
# the scope of the event that issues the commands and
# eliminate the unexpected residual effect of such commands
# that may have been issued by other events.
#
# PB v11.02 -
#
MOM_cancel_suppress_force_once_per_event
}
#=============================================================
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
}
# 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
}
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
set mom_from_pos(0) 0.0 ; set mom_sys_home_pos(0) 0.0
set mom_from_pos(1) 0.0 ; set mom_sys_home_pos(1) 0.0
set mom_from_pos(2) 0.0 ; set mom_sys_home_pos(2) 0.0
}
if { ![info exists mom_sys_tool_change_pos($mom_cycle_spindle_axis)] } {
set mom_sys_tool_change_pos($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 || $is_first_move } {
set mom_last_pos($mom_cycle_spindle_axis) $mom_sys_tool_change_pos($mom_cycle_spindle_axis)
} else {
if { [info exists mom_last_pos($mom_cycle_spindle_axis)] == 0 } {
set mom_last_pos($mom_cycle_spindle_axis) $mom_sys_home_pos($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 $mom_pos($mom_cycle_spindle_axis) $mom_last_pos($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 0
switch $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 machine
if [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 } {
#=============================================================
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 { [CMD_EXIST PB_CMD_before_output] } {
PB_CMD_before_output
}
}
#=============================================================
proc PB_CMD_kin_end_of_path { } {
#=============================================================
# Record tool time for this operation.
if { [CMD_EXIST 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]
#<12-16-2014 gsl> To determine feed mode for RETRACT per motion type
global mom_motion_event
if { ![info exists mom_motion_event] } {
set mom_motion_event UNDEFINED
}
set feed_type RAPID
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 {
#<Sep-07-2016 gsl>
# SUPER_FEED_MODE_SET RAPID
if { [string match "linear_move" $mom_motion_event] ||\
[string match "circular_move" $mom_motion_event] } {
set feed_type CONTOUR
}
}
default {
#<Sep-07-2016 gsl>
if { !([EQ_is_zero $f_pm] && [EQ_is_zero $f_pr]) } {
set feed_type CONTOUR
}
}
}
#<Sep-07-2016 gsl>
if { ![string match "CYCLE" $mom_motion_type] } {
SUPER_FEED_MODE_SET $feed_type
}
# 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 CONTOUR
}
}
}
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"
}
}
}
# Post Builder provided format for the current mode:
if { [info exists mom_sys_feed_param(${feed_mode},format)] } {
MOM_set_address_format F $mom_sys_feed_param(${feed_mode},format)
} else {
switch $feed_mode {
IPM -
MMPM -
IPR -
MMPR -
DPM -
FRN { MOM_set_address_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 { [CMD_EXIST 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] } {
# 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] } {
# Execute start of head callback in new post's context.
global CURRENT_HEAD
if { [info exists CURRENT_HEAD] && [CMD_EXIST PB_start_of_HEAD__$CURRENT_HEAD] } {
PB_start_of_HEAD__$CURRENT_HEAD
}
# Restore master start & end of program handlers
if { [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 handler
if { [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
if { [info exists mom_kin_machine_type] } {
if { ![string match "*3_axis_mill*" $mom_kin_machine_type] &&\
![string match "*lathe*" $mom_kin_machine_type] } {
# <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.
#=============================================================
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 $mom_arc_angle > 180.0] {
set mom_arc_radius [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]] } {
#<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.0
MOM_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 using a secondary post.
#
# ==> It's advisable NOT to use the active post and the same
# output file for this secondary posting job.
# ==> Ensure legitimate and fully qualified file path for post processor and
# the output file are specified (in platform convention) for the command.
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# CAUTION - Comment out next line to activate this function!
return
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#=============================================================
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_move
global mom_sys_first_linear_move
if { ![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_plane
set 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 ABORT_EVENT_CHECK { } {
#=============================================================
# Called by every motion event to abort its handler based on
# the setting of mom_sys_abort_next_event.
#
if { [info exists ::mom_sys_abort_next_event] && $::mom_sys_abort_next_event } {
if { [CMD_EXIST PB_CMD_kin_abort_event] } {
PB_CMD_kin_abort_event
}
}
}
#=============================================================
proc ARCTAN { y x } {
#=============================================================
global PI
if { [EQ_is_zero $y] } { set y 0 }
if { [EQ_is_zero $x] } { set x 0 }
#=============================================================
proc ARR_sort_array_to_list { ARR {by_value 0} {by_decr 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
# by_decr : 0 Sort into increasing order (default)
# 1 Sort into decreasing order
#
# Return a list of {name value} couplets
#
#-------------------------------------------------------------
# Feb-24-2016 gsl - Added by_decr flag
#
upvar $ARR arr
set list
foreach { e v } [array get arr] {
lappend list "$e $v"
}
set val [lindex [lindex $list 0] $by_value]
if { $by_decr } {
set trend "decreasing"
} else {
set trend "increasing"
}
if [expr $::tcl_version > 8.1] {
if [string is integer "$val"] {
set list [lsort -integer -$trend -index $by_value $list]
} elseif [string is double "$val"] {
set list [lsort -real -$trend -index $by_value $list]
} else {
set list [lsort -dictionary -$trend -index $by_value $list]
}
} else {
set list [lsort -dictionary -$trend -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-2010 gsl - Initial implementation
# 03-09-2011 gsl - Enhanced description
# 06-29-2018 gsl - Only compare the 0th element in command string
#
if { [info level] <= 2 } {
return 0
}
if { ![string compare "$caller" [lindex [info level -2] 0] ] } {
return 1
} else {
if { $out_warn } {
CATCH_WARNING "\"[lindex [info level -1] 0]\" cannot be executed in \"[lindex [info level -2] 0]\". \
It must be called by \"$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_buffer
if { ![info exists mom_o_buffer] } {
set mom_o_buffer ""
}
if { ![info exists mom_motion_event] } {
set mom_motion_event ""
}
# 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 { $out_warn } {
CATCH_WARNING "Command \"$cmd\" called by \"[lindex [info level -1] 0]\" does not exist!"
}
return 0
}
}
#=============================================================================
proc COMPARE_NX_VERSION { this_ver target_ver } {
#=============================================================================
# Compare a given NX version with target version.
# ==> Number of fields will be compared based on the number of "." contained in target.
#
# Return 1: Newer
# 0: Same
# -1: Older
#
set vlist_1 [split $this_ver "."]
set vlist_2 [split $target_ver "."]
set ver_check 0
set idx 0
foreach v2 $vlist_2 {
if { $ver_check == 0 } {
set v1 [lindex $vlist_1 $idx]
if { $v1 > $v2 } {
set ver_check 1
} elseif { $v1 == $v2 } {
set ver_check 0
} else {
set ver_check -1
}
}
#=============================================================
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 output
set result_file "$env(TEMP)/${mom_logname}__EXEC_[clock clicks].out"
#=============================================================
proc GET_SUBOP_MOVE_NAME { move_type } {
#=============================================================
# Aug-15-2018 gsl - Return GMC subop name of interOp path
#
switch $move_type {
10 {
set move_name "Tool_Change_Container"
}
11 {
set move_name "Tool_Change_Position"
}
12 {
set move_name "Rotary_Tool_Center_Point_On"
}
13 {
set move_name "Rotary_Tool_Center_Point_Off"
}
115 {
set move_name "Move_to_Machine_Position"
}
810 {
set move_name "Rotary_Point_Vector_Move"
}
default {
set move_name "Unknown"
}
}
return $move_name
}
#=============================================================
proc HANDLE_FIRST_LINEAR_MOVE { } {
#=============================================================
# Called by MOM_linear_move to handle the 1st linear move of an operation.
#
if { ![info exists ::first_linear_move] } {
set ::first_linear_move 0
}
if { !$::first_linear_move } {
PB_first_linear_move
incr ::first_linear_move
}
}
#=============================================================================
proc INIT_VAR { VAR {_val 0} } {
#=============================================================================
# 10/31/2018 gsl - Initialize a variable if absent.
#
# - By default, the variable in question will be initialized to "0",
# unless a desired value is supplied.
#
upvar $VAR _var
if { ![info exists _var] } { set _var $_val }
}
#=============================================================
proc LIMIT_ANGLE { a } {
#=============================================================
set a [expr fmod($a,360)]
set a [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} } {
#=============================================================
# This command will output a single or a set of operator message(s).
#
# msg : Message(s separated by new-line character)
# seq_no : 0 Output message without sequence number (Default)
# 1 Output message with sequence number
#
foreach s [split $msg \n] {
set s1 "$::mom_sys_control_out $s $::mom_sys_control_in"
if { !$seq_no } {
MOM_suppress once N
}
MOM_output_literal $s1
}
set ::mom_o_buffer ""
}
#=============================================================
proc OUTPUT_MACRO { macro_string suppress_seqno } {
#=============================================================
# This command will be called in PB_call_macro to split a macro string
# into multiple lines of output by the separator "{n}" token.
#
# 03-04-2019 gsl - New
# 08-11-2019 lili - Fix split string_list issue.
#
# - Uncomment next line to display debug message -
# OPERATOR_MSG "MACRO_STRING : $macro_string"
set seqno_status [MOM_set_seq_off]
if { [string match "on" $seqno_status] } { MOM_set_seq_on }
if { [string match "on" $seqno_status] && $suppress_seqno } {
set suppress_seqno 1
} else {
set suppress_seqno 0
}
# Define split_str -
set split_str "\{n\}"
set string_list [split [string map [list $split_str \0] $macro_string] \0]
set list_len [llength $string_list]
set blank ""
set i 0
foreach s $string_list {
if { $i == 0 } {
if { $suppress_seqno } {
MOM_suppress once N
MOM_output_literal $s
} else {
MOM_output_literal $s
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_logname
set pause_file_name "$env(TEMP)/${mom_logname}_mom_pause_[clock clicks].txt"
if [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 $fid
file delete -force $pause_file_name
set gPB(PB_disable_MOM_pause) 1
uplevel #0 {
if { [CMD_EXIST MOM_abort_program] } {
MOM_abort_program "*** User Abort Post Processing *** "
} else {
MOM_abort "*** User Abort Post Processing *** "
}
}
}
default {}
}
######
# Delete the scratch file
######
close $fid
file delete -force $pause_file_name
}
}
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 { [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) 1
uplevel #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 "$str" "$var"] } {
return 1
} else {
if { $out_warn && ![info exists var] } {
CATCH_WARNING "Variable $VAR is not defined in \"[lindex [info level -1] 0]\"!"
}
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 < $level } {
set str "${str}[lindex [info level $i] 0]\n"
} else {
set str "${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 {
set VAR [string trim $VAR]
if { $VAR != "" } {
upvar $VAR var
if { [array exists var] } {
if { [expr $::tcl_version > 8.1] } {
array unset var
} else {
foreach a [array names var] {
if { [info exists var($a)] } {
unset var($a)
}
}
unset var
}
}
for { set i 0 } { $i < $n } { incr i } {
set v2($i) $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]
# 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 ${var}($item)] } {
set ${var}($item) [expr [set ${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"