一个在CAD中实现G代码生成的二次开发.
一个在CAD中实现G代码生成的二次开发.借鉴高飞大侠的像素功能,界面丰富了很多.
将白色过滤掉
(defun putb(ff/ *error* dch dcl des i images
j x y R G B W
H wStr hStr rStr key ColorObj
DCLHead DCLList DCLTail ImageHead IndexColor
Version
);;读取文本文件
(defun RGB->Index (ColorObj r g b / i)
;;; (if (or (and (equal 0 r 10) (equal 0 g 10) (equal 0 b 10))
;;; (and (equal 255 r 10) (equal 255 g 10) (equal 255 b 10))
;;; )
(if (and (equal 0 r 10) (equal 0 g 10) (equal 0 b 10))
-15 ;It should be 0,but if you have set the CAD background color,then it looks strange.
(progn
(vla-setRGB ColorObj r g b)
(setq i (vla-get-ColorIndex ColorObj))
(if (= i 7) ;A little confused!
255
i
)
)
)
)
(setq images (load(strcat "c:\\ourscad\\pic\\" ff ".lsp")))
(setq ffff (open (strcat "c:\\ourscad\\pic\\" ff ".lsp") "r"))
(setq file (open (strcat "c:\\ourscad\\pic\\" ff "12.lsp") "w"))
;;;(setq file (open "c:/OURSCAD/hanzi.wmf" "w"))
;(setq str (read-line f))
(write-line (read-line ffff) file)
(and (null Images) (exit))
;;获取CAD颜色对象,为颜色转化做准备
(setq Version (substr (getvar 'acadver) 1 2))
(setq Version (strcat "AutoCAD.AcCmColor." version))
(setq ColorObj (vlax-create-object version))
(setq i 0)
(foreach image Images
(foreach pt (cdr Image)
(setq x (car pt))
(setq y (cadr pt))
(setq r (nth 2 pt))
(setq g (nth 3 pt))
(setq b (nth 4 pt))
(setq IndexColor (RGB->Index ColorObj r g b))
(write-line (vl-prin1-to-string (list x y IndexColor)) file)
)
(end_image)
(setq i (1+ i))
)
(write-line "))" file)
(Close file)(close ffff)
(and ColorObj (vlax-release-object ColorObj))
(setq ffff (open (strcat "c:\\ourscad\\pic\\" ff ".lsp") "r"))
(setq file (open (strcat "c:\\ourscad\\pic\\" ff "bak.lsp") "w"))
(setq str (read-line ffff))
(write-line str file)
(while (setq str (read-line ffff))
(write-line str file)
)
(close ffff)(Close file)
(setq ffff (open (strcat "c:\\ourscad\\pic\\" ff ".lsp") "w"))
(setq file (open (strcat "c:\\ourscad\\pic\\" ff "12.lsp") "r"))
(setq str (read-line file))
(write-line str ffff)
(while (setq str (read-line file))
(setq lll (strlen str))
(cond
((< lll 4) (write-line str ffff))
((and (>= lll 4)(/= "255)" (substr str (- lll 3))))
; ((and (>= lll 4)(/= "5)" (substr str (- lll 1))))
(write-line str ffff))
)
; (write-line str ffff)
)
(close ffff)(Close file)
(princ)
)
FF为文件名.xs为倍数
(defun put(ff xs / *error* dch dcl des i images
j x y R G B W
H wStr hStr rStr key ColorObj
DCLHead DCLList DCLTail ImageHead IndexColor
IC
);;读取文本文件,xs为正整数
(setq images (load(strcat "c:\\ourscad\\pic\\" ff ".lsp")))
(and (null Images) (exit))
;;填充图像控件
(setq i 0)
(foreach image Images
(foreach pt (cdr Image)
(setq x (car pt))
(setq y (cadr pt))
(setq ic (nth 2 pt))
; (fill_image x y 1 1 ic)
;;; (if (/= 255 ic)
(fill_image (* xs x)(* xs y) xs xs ic)
;;; (fill_image (* xs x)(* xs y) xs xs ic)
;;; )
)
(end_image)
(setq i (1+ i))
)
;;开始对话框演示
;;;(and (< 0 dch) (unload_dialog dch))
(and ColorObj (vlax-release-object ColorObj))
(princ)
) 前生 发表于 2017-10-16 11:15
乱七八糟的有60M,有需要的朋友,发邮件给我.我发邮件给大家.谢谢!
这个主要是针对冲压模具CNC加工的备料程 ...
钱先生,您好,能否发一下您的CAD中二次开发做刀路生成G代码的程序,在此万分感谢,我是从事CNC锣床加工的,平时机器主要切割些木板、PVC塑胶板,比较简单,但是量非常大。
我的邮件464190200@qq.com, 我发信息到您的邮件 最终界面确定。
点击。右边的键,呈绿色,中间显示相关的工作内容。
这几天,琢磨下来。CAD中自己带的slide_image
估计就是优化的vector_image以及fill_image
像带线宽的线做成的SLD文件,显示的很怪,也许
就是可以按比例放大以及缩小SLD文件所至。
效果不错,我还是觉得幻灯片好 东西不错。。源码在哪?工具在哪啊??? 没有东西呀 maxli 发表于 2017-10-15 08:56
东西不错。。源码在哪?工具在哪啊???
你是要写图片的工具还是编程的工具? 【KAIXIN】 发表于 2017-10-15 08:54
效果不错,我还是觉得幻灯片好
其实,都差不多吧.
也是这几天实在是没有事干,弄弄看看效果,以及看看显示的速度怎么样?
其实速度还好. 没经币了----
演示,
这个GIF的录制软件,不咋的啊/
哪位有好一点常用的.谢谢!
看着眼花,习惯后应该没影响 本帖最后由 前生 于 2017-10-15 20:14 编辑
仲文玉 发表于 2017-10-15 16:54
看着眼花,习惯后应该没影响
CNC加工决定了其复杂{:1_1:}