请教AUTOLISP编程高手帮忙编写程序,很急!!!
以上零件分瓣下料图是把一个圆形零件分成几个不同等分下料的图,我在网上刚好找到一个类似的AUTOLISP程序,但是在CAD里却运行不起来。请教AUTOLISP编程高手,为什...
以上零件分瓣下料图是把一个圆形零件分成几个不同等分下料的图,我在网上刚好找到一个类似的AUTOLISP程序,但是在CAD里却运行不起来。请教AUTOLISP编程高手,为什么此程序运行不起来?如果错误的话,请高手指点,帮忙重新写一下程序,谢谢!(注意:程序中自动排料时需要计算相邻两扇形所围成的月牙形状内外圆弧中点之间的距离尺寸,并加上适当的割缝宽度作为间隙,依次排料。)
(defun c:yuanhuan()
(command "osnap" "off")
(alert "圆环分瓣下料,若不是整圆,请按照提示输入圆环中心夹角。注意:未考虑加工余量,需要加工时须输入带加工余量的尺寸")
(setq Rw (getreal "\n请输入大圆直径mm:"))
(setq Rn (getreal "\n请输入小圆直径mm:"))
(if (>= Rn Rw)
(progn (alert "错误!小圆直径>=大圆直径")
(exit))
)
(setq a (getreal "\n请输入圆环夹角<360>"))
(if (= a nil ) (setq a 360))
(setq aa (* (/ a 180) pi));;degtorad
(setq hfkd (getint "\n请输入割缝宽度-请取整数值mm:"))
(if(= hfkd nill)
(progn (alert "注意!割缝宽度为0")
(setq hfkd 0))
)
(setq N (getint "\n请输入等分数量:"))
(setq al (/ a (* n 2)))
(setq Rw (/ Rw 2))
(setq Rn (/ Rn 2))
(setq da (/ aa (* N 2)))
(setq l (* Rn (sin da)))
(setq conda (* (/270 180) pi))
(setq bb (- conda da))
(setq cc (+ conda da))
(setq b (- 270 al))
(setq c (+ 270 al))
(setq l (expt l 2))
(setq Rw1 (expt Rw 2))
(setq Rn1 (expt Rn 2))
(setq delta (- (sqrt (- Rw1 l)) (sqrt(- Rn1 l))))
(setq str11 (strcat "@" (rtos Rn) "<" (rots b)))
(setq str12 (strcat "@" (rtos Rn) "<" (rots c)))
(setq str21 (strcat "@" (rtos Rw) "<" (rots b)))
(setq str22 (strcat "@" (rtos Rw) "<" (rots c)))
;;;begin to drawing
(setq p1 (getpoint "\n请指定起始圆心点:"))
(command "ucs" "move" p1)
(setq i 1)
(setq x11 (* Rn (sin da)))
(setq x12 (* (* Rn (sin da)) -1))
(setq y1 (* (* Rn (cos da)) -1))
(setq x21 (* Rw (sin da)))
(setq x22 (* (* Rw (sin da)) -1))
(setq y2 (* (* Rw (cos da)) -1))
(setq lstr1 (strcat (rtos x11) "," (rtos y1)))
(setq lstr2 (strcat (rtos x12) "," (rtos y1)))
(setq lstr3 (strcat (rtos x21) "," (rtos y2)))
(setq lstr4 (strcat (rtos x22) "," (rtos y2)))
(while (<= i n)
(commad "arc" "c" "0,0" str11 str12)
(commad "arc" "c" "0,0" str21 str22)
(commad "line" lstr1 lstr3 "")
(commad "line" lstr2 lstr4 "")
(setq x 0)
(setq y 0)
(setq y (+ y delta))
(setq y (+ y hfkd));;;割缝宽度
(setq x (rtos x))
(setq y (rtos y))
(setq ptem ('strcat x "," y))
(command "ucs" "move" ptem)
(setq i (1 + i))
)
(command "-osnap" "end,mid,cen,int")
(command "regen")
(command "zoom" "all")
(princ)
)
如果哪位高手有兴趣帮助我,留QQ给我,我的QQ:511590487。我是做工艺设计的,最近公司里要搞工艺方面的改进,牵涉到零件怎样自动排料。《基于AutoLISP程序的圆环零件排料设计》这是我在网上找到的文章,图和程序都是我需要的,只是他的程序我运行不起来。 展开
(defun c:yuanhuan()
(command "osnap" "off")
(alert "圆环分瓣下料,若不是整圆,请按照提示输入圆环中心夹角。注意:未考虑加工余量,需要加工时须输入带加工余量的尺寸")
(setq Rw (getreal "\n请输入大圆直径mm:"))
(setq Rn (getreal "\n请输入小圆直径mm:"))
(if (>= Rn Rw)
(progn (alert "错误!小圆直径>=大圆直径")
(exit))
)
(setq a (getreal "\n请输入圆环夹角<360>"))
(if (= a nil ) (setq a 360))
(setq aa (* (/ a 180) pi));;degtorad
(setq hfkd (getint "\n请输入割缝宽度-请取整数值mm:"))
(if(= hfkd nill)
(progn (alert "注意!割缝宽度为0")
(setq hfkd 0))
)
(setq N (getint "\n请输入等分数量:"))
(setq al (/ a (* n 2)))
(setq Rw (/ Rw 2))
(setq Rn (/ Rn 2))
(setq da (/ aa (* N 2)))
(setq l (* Rn (sin da)))
(setq conda (* (/270 180) pi))
(setq bb (- conda da))
(setq cc (+ conda da))
(setq b (- 270 al))
(setq c (+ 270 al))
(setq l (expt l 2))
(setq Rw1 (expt Rw 2))
(setq Rn1 (expt Rn 2))
(setq delta (- (sqrt (- Rw1 l)) (sqrt(- Rn1 l))))
(setq str11 (strcat "@" (rtos Rn) "<" (rots b)))
(setq str12 (strcat "@" (rtos Rn) "<" (rots c)))
(setq str21 (strcat "@" (rtos Rw) "<" (rots b)))
(setq str22 (strcat "@" (rtos Rw) "<" (rots c)))
;;;begin to drawing
(setq p1 (getpoint "\n请指定起始圆心点:"))
(command "ucs" "move" p1)
(setq i 1)
(setq x11 (* Rn (sin da)))
(setq x12 (* (* Rn (sin da)) -1))
(setq y1 (* (* Rn (cos da)) -1))
(setq x21 (* Rw (sin da)))
(setq x22 (* (* Rw (sin da)) -1))
(setq y2 (* (* Rw (cos da)) -1))
(setq lstr1 (strcat (rtos x11) "," (rtos y1)))
(setq lstr2 (strcat (rtos x12) "," (rtos y1)))
(setq lstr3 (strcat (rtos x21) "," (rtos y2)))
(setq lstr4 (strcat (rtos x22) "," (rtos y2)))
(while (<= i n)
(commad "arc" "c" "0,0" str11 str12)
(commad "arc" "c" "0,0" str21 str22)
(commad "line" lstr1 lstr3 "")
(commad "line" lstr2 lstr4 "")
(setq x 0)
(setq y 0)
(setq y (+ y delta))
(setq y (+ y hfkd));;;割缝宽度
(setq x (rtos x))
(setq y (rtos y))
(setq ptem ('strcat x "," y))
(command "ucs" "move" ptem)
(setq i (1 + i))
)
(command "-osnap" "end,mid,cen,int")
(command "regen")
(command "zoom" "all")
(princ)
)
如果哪位高手有兴趣帮助我,留QQ给我,我的QQ:511590487。我是做工艺设计的,最近公司里要搞工艺方面的改进,牵涉到零件怎样自动排料。《基于AutoLISP程序的圆环零件排料设计》这是我在网上找到的文章,图和程序都是我需要的,只是他的程序我运行不起来。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询