一段LSP语言
(defun c:cced(/ f fn ff e0 dwg a i)(command"sh""deldxf")
(initget(+ 2 4))(princ"\n ")
(setq dwg(getvar"DWGNAME"))
(setq a(strlen dwg)i a)
(while(> i 0)
(if(= (substr dwg i 1)"\\")(setq dwg(substr dwg(+ i 1)(+ (- a i)1))i 1))
(setq i(- i 1))
)
(while a
(setq e0(strcat"\n请输入线切割文件名,不支持长文件名:<"">"))
(setq fn(getstring e0))
(if(= fn "")(setq fn dwg))
(setq f(strcat "c:/wc/"fn".dxf"))
(setq ff(open f"r"))
(cond((/= ff nil)
(princ"\n")(princ" 有同名文件")(princ" 要覆盖它吗?")
(princ"确认按空格:")
(setq a(getint" "))
(close ff)
)
((= ff nil)(setq a nil))
)
)
(redraw)(princ"\n ")(princ"\n ")
(princ "\n选切割曲线,目标不能为多义线或样条曲线,如为多义线请炸开,样条曲线请转换成弧或直线:")
(setq s1(ssget))
(setq laa"ok")
(setq cla(getvar"CLAYER"))
(if(/= laa cla)(command "layer""NEW"LAA"off"laa""))
(command "CHprop"s1"""la"laa"")
(cond((/= laa cla)
(command "layer""NEW"LAA"off"laa"")
(command "layer""ON"LAA"s"laa"off"cla"")
)
)
(setq e0(getpoint"\n起点: "))
(princ"\n稍候...")(princ"\n ")
(setq ff(strcat fn".STP"))
(setq f"c:/wc/"f(strcat f ff))
(setq f(open f"w"))
(princ(car e0)f)(princ"\n"f)
(princ(nth 1 e0)f)(princ"\n"f)
(close f)
(setq f"c:/wc/"f(strcat f fn))
(command"dxfout"f 8)(princ"\n ")(princ"\n ")
(setq ff(open "c:/wc/zanechen.fn""w"))
(princ fn ff)(princ"\n"ff)(close ff)
(command"sh""dv""REDRAW")
(command "CHprop"s1"""la"cla"")
(if(/= laa cla)(command "layer""ON"cla"s"cla"off"laa""))
)
(defun c:3b ()
(command"sh""3b""redraw")
)
补充下上次出了点意外没说清楚目的
想问下直接把这段加到acad.lsp里可以用吗!小弟菜菜怕把cad整崩溃了麻烦高手指教下
页:
[1]