|
本帖最后由 tombai691019 于 2024-2-1 17:33 编辑
在旧版后处理构造器中可以加代码使每个工序都输出换刀命令,在换刀命令后面可以写代码输出Zmax,Zmin等。现在玩PC的少了,新版后理配置器中怎么在每个工序都输出换刀命令,并在换刀命令后输出Zmax,Zmin,刀号,刀具直径及刀补信息。这样可以使程序更容易看懂,每个工序都是什么刀具在加工及刀补信息。这里分享可以实现这个功能的代码。与旧版构造器相比,实现相同功能,后处理配置更方便,代码相对来说简单一些(把代码粘上来)
代码段1
MOM_do_template tool_change
global mom_tool_name zmin zmax Tnumber Tname Tdd Tddd d_cutcom xystock zstock mom_stock_floor mom_stock_type mom_operstion_type mom_stock_part mom_tool_type tool_type
set zmin [LIB_SPF_get_pretreatment limit,z,min 0 ]
set zmax [LIB_SPF_get_pretreatment limit,z,max 0 ]
set Tnumber [LIB_SPF_get_pretreatment mom_tool_number 0 ]
set Tname [LIB_SPF_get_pretreatment mom_tool_name 0 ]
set Tdd [LIB_SPF_get_pretreatment mom_tool_cutcom_register 0 ]
set d_cutcom [LIB_SPF_get_pretreatment mom_cutcom_type 0 ]
set tool_type [LIB_SPF_get_pretreatment mom_tool_type 0 ]
if { $d_cutcom == 0 } {
set Tddd "D-"
} else {
set Tddd "D$Tdd"
}
MOM_output_literal "([format "%-2s %-3s %-3s %-10s %-7s" T$Tnumber $Tname $Tddd Zmin=$zmin Zmax=$zmax])"
if {$mom_tool_type == "Drilling Tool"} {
set xystock 0
set zstock 0
} else {
if { [info exists mom_stock_part]} {
set xystock [LIB_SPF_get_pretreatment mom_stock_part 0 ]
}
if {[info exists mom_stock_floor]} {
if {[info exists mom_stock_part_use]} {
if { $mom_stock_part_use == 1} {
#底部余量:
set zstock [LIB_SPF_get_pretreatment mom_stock_part 0]
return
}
}
#底部余量:
set zstock [LIB_SPF_get_pretreatment mom_stock_floor 0]
}
MOM_output_literal "(XYstock=[format "%.2f" $xystock],Zstock= [format "%.2f" $zstock ])"
#MOM_do_template tool_change
}
代码段2
proc MOM_first_move_LIB_ENTRY {position} {
switch -- $position {
"start"
{
#Your code before the event goes here
MOM_force once T
MOM_do_template tool_change
global mom_tool_name zmin zmax Tnumber Tname Tdd Tddd d_cutcom xystock zstock mom_stock_floor mom_stock_type mom_operstion_type mom_stock_part mom_tool_type tool_type
set zmin [LIB_SPF_get_pretreatment limit,z,min 0 ]
set zmax [LIB_SPF_get_pretreatment limit,z,max 0 ]
set Tnumber [LIB_SPF_get_pretreatment mom_tool_number 0 ]
set Tname [LIB_SPF_get_pretreatment mom_tool_name 0 ]
set Tdd [LIB_SPF_get_pretreatment mom_tool_cutcom_register 0 ]
set d_cutcom [LIB_SPF_get_pretreatment mom_cutcom_type 0 ]
set tool_type [LIB_SPF_get_pretreatment mom_tool_type 0 ]
if { $d_cutcom == 0 } {
set Tddd "D-"
} else {
set Tddd "D$Tdd"
}
MOM_output_literal "([format "%-2s %-3s %-3s %-10s %-7s" T$Tnumber $Tname $Tddd Zmin=$zmin Zmax=$zmax])"
if {$mom_tool_type == "Drilling Tool"} {
set xystock 0
set zstock 0
} else {
if { [info exists mom_stock_part]} {
set xystock [LIB_SPF_get_pretreatment mom_stock_part 0 ]
}
if {[info exists mom_stock_floor]} {
if {[info exists mom_stock_part_use]} {
if { $mom_stock_part_use == 1} {
#底部余量:
set zstock [LIB_SPF_get_pretreatment mom_stock_part 0]
return
}
}
#底部余量:
set zstock [LIB_SPF_get_pretreatment mom_stock_floor 0]
}
MOM_output_literal "(XYstock=[format "%.2f" $xystock],Zstock= [format "%.2f" $zstock ])"
#MOM_do_template tool_change
}
MOM_force once G_motion G_mysys G_mode G_adjust H S M M_spindle M_coolant Z X Y T F_mytap Q_mytap
MOM_do_template rapid_move_first_move
#MOM_force once G_adjust H S M M_spindle M_coolant Z X Y T
MOM_do_template rapid_move_first_G43
}
"end"
{
#Your code after the event goes here
# MOM_force once T
#MOM_do_template tool_change
#MOM_force once G_motion G_mode G_adjust H S M M_spindle M_coolant Z X Y T
#MOM_do_template rapid_move_first_move
#MOM_force once G_adjust H S M M_spindle M_coolant Z X Y T
# MOM_do_template rapid_move_first_G43
}
}
}
|
|