yth0407 发表于 2008-6-24 14:14:00

[求助]求转加工中心铣斜度程式的LISP程序

求转加工中心铣斜度程式的LISP程序,有疑问请跟贴.谢谢.

ZZXXQQ 发表于 2008-7-16 22:07:00

本帖最后由 ZZXXQQ 于 2018-3-8 13:14 编辑

又改了,再试试。


;;;功能: 铣斜槽
;;;编程: ZZXXQQ
;;;时间: 2008-07-01,2008-07-18
(defun c:xxc ()
(setq ppl (list) txtl (list) k 1)
(while (and
   (setq tools (getint (strcat "\n刀具号 <" (if (numberp tool) (itoa tool) "1") "> :"))
            tool (if tools tools tool)
            tool (if tool tool 1))
   (setq d1 (getdist (strcat "\n刀具直径 <" (if (numberp d) (rtos d 2 3) "6") "> :"))
            d (if d1 d1 d)
            d (if d d 6))
   (setq pt2 (getpoint "\n选取进刀点 :"))
   (setq pt3 (getpoint "\n选取出刀点 :")))
   (setq ppl (cons (strcat "M06 T" (itoa tool) "(D=" (rtos d 2 3) ");\n") ppl)
            txtl (cons (strcat "N" (itoa k) "=T" (itoa tool) "(D=%%c" (rtos d 2 2) ")") txtl)
            ppl (cons "M08;\n" ppl)
            ppl (cons "G80 G90 G54 F80;\n" ppl)
            ppl (cons (strcat "G00 X0.0 Y0.0 MO3 S" (rtos (/ 10800 d) 2 3) ";\n") ppl)
            ppl (cons "G43 H52 Z5.0;\n" ppl)
            ppl (cons "G01 F1500 Z5.0;\n" ppl)
            ppl (cons (strcat "N" (itoa k) ";\n") ppl)
            ppl (cons (strcat "G00 X" (rtos (car pt2) 2 3) " Y" (rtos (cadr pt2) 2 3) ";\n") ppl)
            ppl (cons "G01 Z0.0 F1000;\n" ppl)
            ppl (cons (strcat "X" (rtos (car pt2) 2 3) " Y" (rtos (cadr pt2) 2 3) " F200;\n") ppl)
            ppl (cons (strcat "X" (rtos (car pt3) 2 3) " Y" (rtos (cadr pt3) 2 3) " Z-15.0;\n") ppl)
            ppl (cons "G00 Z5.0;\n" ppl)
            ppl (cons "M01;\n" ppl)
            k (1+ k))
(if (> (cdr(assoc 40 (tblsearch "STYLE" (getvar "TEXTSTYLE")))) 0)
   (command ".text" pt3 "" "" (strcat "N" (itoa (1- k))))
   (command ".text" pt3 "" "" (strcat "N" (itoa (1- k))))
)
)
(setq ppl (reverse ppl) txtl (reverse txtl))
(setq nm (if nm nm ""))
(if (setq nm (getfiled "Select File Name 选择文件名" nm "nc" 9)) (progn
(setq i (strlen nm))
(while (/= (setq tmptx (substr nm i 1)) "\\") (setq i (1- i)))
(setq txtl (cons (strcat "斜边加工程式文件名:" (substr nm (1+ i))) txtl))
(setq fp (open nm "w"))
(princ "%;\n" fp)
(princ (strcat "(" (substr nm (1+ i)) ");\n") fp)
(setq i 0)
(repeat (length ppl)
   (princ (nth i ppl) fp)
   (setq i (1+ i))
)
(princ "G49 Z5.0;\n" fp)
(princ "G28 X0.0 Y0.0;\n" fp)
(princ "M30;\n" fp)
(princ "%;\n" fp)
(close fp)
(setq i 1)
(if (setq pt (getpoint "\nText Insert Point 文字插入点:")) (progn
   (if (> (cdr(assoc 40 (tblsearch "STYLE" (getvar "TEXTSTYLE")))) 0)
    (command ".text" pt "" (car txtl))
    (command ".text" pt "" "" (car txtl))
   )
   (repeat (1- (length txtl))
    (command ".text" "" (nth i txtl))
    (setq i (1+ i))
   )
))
(startapp "notepad" nm)
))
(princ)
)

ZZXXQQ 发表于 2008-6-25 20:00:00

给个示意图或调试图样。

yth0407 发表于 2008-6-30 09:40:00

<p></p><p>要求步骤:输入命令----输入刀具大小-----选择起点---(重复输入刀具大小,最好能默认上一次输入)---回车--选择说明文字放置点--程式转换成功</p><p>功能:转出程式后能标记abcd并在图侧说明文字 转出的程式另存为文本文件默认保存在C:\NC目录下&nbsp;</p><p></p>

ZZXXQQ 发表于 2008-6-30 14:22:00

<p>看图样是铣键槽,但看程序键槽底部是斜的,这样的加工方法槽底不是平的。</p><p>问题:程序的起点在哪里?哪边高?如果刀具直径小用是否插补方式铣?是否要指定刀具原点?</p>

yth0407 发表于 2008-6-30 14:54:00

<p>槽底是平的,例:30厚的板,只有15是斜的.</p><p>问题:程序的起点是在标示Z-15的地方(就是在槽里面的那个点), 我可以写成我选哪个点那个点就为起点</p><p>标示Z0.0是高的那边(就是在槽外的那边),</p><p>我的意思是铣刀先下到Z-15的地方 再X轴(或Y轴),Z轴一起动铣到Z0.0的位置,一般情况XY轴只要一条轴动的,因为槽是先铣好的,槽多大就用多大的铣刀,所以基本上是不用插补的.如果版主有空的话能写成如果刀具直径比槽小就用插补方式铣的话就最好了.</p><p>要指定刀具原点的.</p><p>其实我要的程序就是转一条线两点坐标的,起点就是Z-15 另一点就是Z0.0 这样铣出来成斜度的,版主别想的太复杂了.</p>

yth0407 发表于 2008-7-1 15:41:00

zzxxqq兄..拜托了..

ZZXXQQ 发表于 2008-7-1 23:50:00



;;;功能: 铣斜槽
;;;编程: ZZXXQQ
;;;时间: 2008-07-01 香港回归11周年纪日
(defun c:xc ()
 (setq ppl (list) k 1)
 (while (and (setq d (getdist "\n刀具直径 :"))
          (setq tool (getint "\n刀具号 :"))
          (setq pt1 (getpoint "\n选取刀具原点 :"))
          (setq pt2 (getpoint "\n选取进刀点 :"))
     (setq pt3 (getpoint "\n选取出刀点 :")))
  (setq ppl (cons (strcat "M06 T" (itoa tool) "(D=" (rtos d 2 3) ";\n") ppl)
        ppl (cons "M08;\n" ppl)
 ppl (cons "G80 G90 G54 F80;\n" ppl)
 ppl (cons (strcat "G00 X0.0 Y0.0 MO3 S" (rtos (/ 10800 d) 2 3) ";\n") ppl)
 ppl (cons "G43 H52 Z5.0;\n" ppl)
 ppl (cons "G01 F1500 Z5.0;\n" ppl)
 ppl (cons (strcat "N" (itoa k) ";\n") ppl)
 ppl (cons (strcat "G00 X" (rtos (car pt2) 2 3) " Y" (rtos (cadr pt2) 2 3) ";\n") ppl)
 ppl (cons "G01 Z-15.0 F1000;\n" ppl)
 ppl (cons (strcat "X" (rtos (car pt2) 2 3) " Y" (rtos (cadr pt2) 2 3) "F200;\n") ppl)
 ppl (cons (strcat "X" (rtos (car pt3) 2 3) " Y" (rtos (cadr pt3) 2 3) "Z0.0;\n") ppl)
 ppl (cons "G00 Z5.0;\n" ppl)
 ppl (cons "M01;\n" ppl)
 k (1+ k))
 )
 (setq ppl (reverse ppl))
 (setq nm (if nm nm ""))
 (if (setq nm (getfiled "Select File Name 选择文件名" nm "nc" 9)) (progn
  (setq fp (open nm "w"))
  (princ "%;\n" fp)
  (princ (strcat "(" nm ");\n") fp)
  (setq i 0)
  (repeat (length ppl)
 (princ (nth i ppl) fp)
 (setq i (1+ i))
  )
  (princ "G49 Z5.0;\n" fp)
  (princ "G28 X0.0 Y0.0;\n" fp)
  (princ "M30;\n" fp)
  (princ "%;\n" fp)
  (close fp)
 ))
 (princ)
)


yth0407 发表于 2008-7-3 14:59:00

<p>十分感谢ZZXXQQ兄了,希望还能作以下修改,谢谢.</p><p>1,刀具原点与进刀点一致.</p><p>2,加入说明文字 转出程式后能标记abcd或1234并在图侧说明文字 (说明文字格式我在2楼上传的附件), 转出的程式另存为文本文件默认保存在C:\NC目录下&nbsp;</p><p>另ZZXXQQ兄能不能想个办法不要每次都输入刀具大小\刀编号?比如一样的刀具大小铣N个斜度转出来程式格式能不能如下:</p><p>%;<br/>(2.nc);<br/>M06 T1(D=8;<br/>M08;<br/>G80 G90 G54 F80;<br/>G00 X0.0 Y0.0 MO3 S1350;<br/>G43 H52 Z5.0;<br/>G01 F1500 Z5.0;<br/>N1;<br/>G00 X793.557 Y369.86;<br/>G01 Z0,0F1000;<br/>X793.557 Y369.86F200;<br/>X723.342 Y369.86Z-15.0;<br/>G00 Z5.0;<br/>M01;<br/>N2;<br/>G00 X558.699 Y366.231;<br/>G01 Z-15.0 F1000;<br/>X558.699 Y366.231F200;<br/>X649.495 Y366.231Z0.0;<br/>G00 Z5.0;<br/>M01;<br/>M06 T2(D=6;<br/>M08;<br/>G80 G90 G54 F80;<br/>G00 X0.0 Y0.0 MO3 S1800;<br/>G43 H52 Z5.0;<br/>G01 F1500 Z5.0;<br/>N3;<br/>G00 X480.522 Y493.99;<br/>G01 Z-15.0 F1000;<br/>X480.522 Y493.99F200;<br/>X656.047 Y493.99Z0.0;<br/>G00 Z5.0;<br/>M01;<br/>G49 Z5.0;<br/>G28 X0.0 Y0.0;<br/>M30;<br/>%;<br/></p><p>再次感谢ZZXXQQ</p>

yth0407 发表于 2008-7-5 14:42:00

<p>等待中...ZZXXQQ版主帮帮忙,小弟十分感激..</p>

yth0407 发表于 2008-7-9 16:24:00

<p>求ZZXXQQ斑主\高手大侠们解决8楼问题,小弟在此谢谢了.</p>
页: [1] 2 3
查看完整版本: [求助]求转加工中心铣斜度程式的LISP程序