QQ登录

只需一步,快速开始

快捷登录

登录 或者 注册 请先

UG爱好者

查看: 3880|回复: 10
打印 上一主题 下一主题

[分享] 孔铣宏程序制作方法

[复制链接]

中校

Rank: 7Rank: 7Rank: 7

35

主题

794

帖子

1万

积分
跳转到指定楼层
楼主
发表于 2022-3-30 08:39:25 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
资料来源于闪光蜗牛
现在给大家分享一下,孔铣命令宏后处理制作方法,只说方法教程,请见谅!
1.新建一个后处理
2.在N/C数据定义模块 →文字  →找到“Z”
3.右键→创建“Z_1”
4.新建选择“文本”格式
5.在N/C数据定义模块 →块  →找到“circular_move”
6.右键→创建“circular_move_1”右键→创建→“circular_move_helix
7.删除“circular_move_1”中的“Z”并添加“Z-1”表达式“#26”
8.删除“circular_move_helix”中的“Z”并添加“Z-1”表达式“#18”
9.在   程序和刀轨 模块→定制命令→导入→在文件夹中选择“pb_cmd_helix.tcl
10.在   程序和刀轨 模块→程序→程序起始序列→添加块右侧选择“PB-CMD-init_helix”→添加块→“%”后即可
11.在   程序和刀轨 模块→定制命令→选择“pb_cmd_helix.tcl”用下面代码替换原代码
12.保存后处理文件,好了,来试一下你的宏程序后处理吧
uplevel #0 {

#

# This ommand will be executed automatically at the start of program and

# anytime it is loaded as a slave post of a linked post.

#

# This procedure can be used to enable your post to output helix.

# You can choose from the following options to format the circle

# block template to output the helix parameters.

#



   set mom_sys_helix_pitch_type    "rise_revolution"



#

# The default setting for mom_sys_helix_pitch_type is "rise_radian".

# This is the most common.  Other choices are:

#

#    "rise_radian"              Measures the rise over one radian.

#    "rise_revolution"          Measures the rise over 360 degrees.

#    "none"                     Will suppress the output of pitch.

#    "other"                    Allows you to calculate the pitch

#                               using your own formula.

#

# This custom command uses the block template circular_move to output

# the helix block.  If your post uses a block template with a different

# name, you must edit the line that outputs the helix block.



#

#  The following variable deines the output mode for helical records.

#

#  FULL_CIRCLE  -- This mode will output a helix record for each 360

#                  degrees of the helix.

#  QUADRANT  --    This mode will output a helix record for each 90

#                  degrees of the helix.

#  LINEAR  --      This mode will output the entire helix as linear gotos.

#  END_POINT --    This mode will assume the control can define an entire

#                  helix in a single block.



   set mom_kin_helical_arc_output_mode END_POINT



   MOM_reload_kinematics





#=============================================================

proc MOM_helix_move { } {

#=============================================================

   global mom_pos_arc_plane

   global mom_sys_cir_vector

   global mom_sys_helix_pitch_type

   global mom_helix_pitch

   global mom_prev_pos mom_pos_arc_center

   global PI





   switch $mom_pos_arc_plane {

      XY { MOM_suppress once K ; set cir_index 2 }

      YZ { MOM_suppress once I ; set cir_index 0 }

      ZX { MOM_suppress once J ; set cir_index 1 }

   }



   switch $mom_sys_helix_pitch_type {

      none { }

      rise_revolution { set pitch $mom_helix_pitch }

      rise_radian { set pitch [expr $mom_helix_pitch / ($PI * 2.0)]}

      other {

#

#    Place your custom helix pitch code here

#

      }

      default { set mom_sys_helix_pitch_type "none" }

   }



   MOM_force once X Y Z



   if { [string compare "none" $mom_sys_helix_pitch_type] } {

      MOM_force once I J K



     #<08-01-06 gsl>

      switch $mom_sys_cir_vector {

         "Vector - Arc Center to Start" {

            set mom_prev_pos($cir_index) $pitch

            set mom_pos_arc_center($cir_index) 0.0

         }

         "Vector - Arc Start to Center" -

         "Unsigned Vector - Arc Start to Center" {

            set mom_prev_pos($cir_index) 0.0

            set mom_pos_arc_center($cir_index) $pitch

         }

         "Vector - Absolute Arc Center" {

            set mom_pos_arc_center($cir_index) $pitch

         }

      }

   }



#

# You may need to edit this line if you output more than one block

# or if you have changed the name of your circular_move block template

#

#   MOM_do_template circular_move

global mom_pos mom_last_pos

set dep [format "%0.3f" [expr $mom_pos($cir_index)-$mom_last_pos($cir_index)]]

set pit [format "%0.3f" $pitch]

set val [string trimright [expr $dep/$pit] .0]

set val_int [expr int($val)]

set z_rem [expr abs(int($dep/$pit)-$dep/$pit)]

if {$mom_pos($cir_index)<$mom_last_pos($cir_index)} {

    set sym GE

} else {

    set sym LE

}

if {$val<1} {

MOM_do_template circular_move

} else {

    MOM_output_literal "(R)#18=[format "%0.3f" [expr $mom_last_pos($cir_index)+$pitch]]
(Z)#26=[format "%0.3f" $mom_pos($cir_index)]
WHILE \[#18 $sym #26\] DO1"

    set last_cycle(0) $mom_pos(0)

    set last_cycle(1) $mom_pos(1)

    set mom_pos(0) $mom_last_pos(0)

    set mom_pos(1) $mom_last_pos(1)

    MOM_do_template circular_move_helix

    MOM_output_literal "#18=#18+\[[format "%0.3f" $pitch]\]
END1"

    if {[string compare $val $val_int]} {

    set mom_pos(0) $last_cycle(0)

    set mom_pos(1) $last_cycle(1)

        MOM_force once X Y Z  I J Z_1

        MOM_do_template circular_move_1

    }

}

}



} ;# uplevel

第一步.png (107.33 KB, 下载次数: 43)

新建后处理文件

新建后处理文件

第二步.png (40.75 KB, 下载次数: 71)

第一步

第一步

第三步.png (42.91 KB, 下载次数: 73)

第二步

第二步

第六步.png (41.09 KB, 下载次数: 57)

第六步.png

第七步.png (129.15 KB, 下载次数: 56)

第六步

第六步

第四步.png (42.63 KB, 下载次数: 71)

第四步.png

第五步.png (41.4 KB, 下载次数: 61)

第四步

第四步

第八步.png (57.89 KB, 下载次数: 63)

第七步

第七步

第九步.png (104.55 KB, 下载次数: 54)

第八步

第八步

有奖推广贴子: 

回复

使用道具 举报

少校

Rank: 6Rank: 6

7

主题

118

帖子

7236

积分
推荐
发表于 2022-4-6 12:04:18 | 只看该作者
感谢大佬,解了我多年的困惑,如果面铣,深度铣也能用宏就好了

微信图片_20220406120217.png (78.89 KB, 下载次数: 62)

微信图片_20220406120217.png
回复 支持 1 反对 0

使用道具 举报

上校

Rank: 7Rank: 7Rank: 7

0

主题

234

帖子

1万

积分
沙发
发表于 2022-3-30 10:04:35 | 只看该作者
非常详细,多谢楼主分享!
回复 支持 反对

使用道具 举报

少校

Rank: 6Rank: 6

1

主题

245

帖子

7192

积分
地板
发表于 2022-3-30 11:18:25 | 只看该作者
多谢楼主分享
回复 支持 反对

使用道具 举报

少尉

Rank: 5Rank: 5

0

主题

54

帖子

2153

积分
5#
发表于 2022-3-30 14:07:53 | 只看该作者
感谢分享 已经成功了
回复 支持 反对

使用道具 举报

少尉

Rank: 5Rank: 5

3

主题

149

帖子

2099

积分
8#
发表于 2022-4-6 15:04:52 | 只看该作者
谢谢大神分享
回复 支持 反对

使用道具 举报

少校

Rank: 6Rank: 6

0

主题

446

帖子

8691

积分
10#
发表于 2022-5-25 19:49:34 | 只看该作者
谢谢大师分享.......
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

 
 
QQ:1359218528
工作时间:
9:00-17:00
 
微信公众号
手机APP
机械社区
微信小程序

手机版|UG爱好者论坛 ( 京ICP备10217105号-2 )    论坛管理员QQ:1359218528

本站信息均由会员发表,不代表本网站立场,如侵犯了您的权利请联系管理员,邮箱:1359218528@qq.com  

Powered by UG爱好者 X3.2  © 2001-2014 Comsenz Inc. GMT+8, 2024-5-28 23:24

返回顶部