求修改lisp程序,如何提取CAD图中多段线的坐标(要当前ucs坐标系)

我的cad图是在当前坐标系里画的,list显示的也是当前坐标系坐标,但我找到以下程序提取出的是世界坐标系的坐标,求高手修改或给出新的程序并作出程序各代码的详细解释,我是l... 我的cad图是在当前坐标系里画的,list显示的也是当前坐标系坐标,但我找到以下程序提取出的是世界坐标系的坐标,求高手修改或给出新的程序并作出程序各代码的详细解释,我是lisp菜鸟。
源程序:
(defun c:zbc (/)
(setvar "cmdecho" 0)
(setq ffn (getfiled "\n保存的坐标文件" "写出的坐标" "txt" 1)
ff (open ffn "w")
ss (ssget '((0 . "*LINE")))
i -1)
(repeat (sslength ss)
(setq ssdata (entget (ssname ss (setq i (1+ i))))
n 0 )
(repeat (length ssdata)
(setq pp (nth n ssdata)
key (car pp) )
(if (= key 10)
(progn
(setq tx
(strcat (rtos (cadr pp) 2 2) " ," (rtos (caddr pp) 2 2)))
(write-line tx ff)) )
(setq n (1+ n)) ))
(close ff)
(princ (strcat "\n 坐标写至=>" ffn))
(princ)
)
展开
 我来答
dnbc1
推荐于2016-06-06 · TA获得超过977个赞
知道小有建树答主
回答量:1235
采纳率:92%
帮助的人:404万
展开全部
(defun c:tqzb (/)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (setq wjm (getfiled "请指定要保存的坐标文件" "e:\\" "txt" 1))
(if (setq ssa (ssget '((0 . "LWPOLYLINE"))))
(progn
(setq fff (open wjm "w")
n (sslength ssa)
i 0
no 0
)
(repeat n
(setq dxf (entget (ssname ssa i))
i (1+ i)
ptb (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= (car x) 10)) dxf))
ptb (mapcar '(lambda(x)(trans x 0 1)) ptb)
)
(foreach pt ptb
(setq no (1+ no))
(write-line (strcat (itoa no) ","
(rtos (car pt) 2 2) ","
(rtos (cadr pt) 2 2) ","
)
fff
)
)
)
(close fff)
(princ (strcat "\n坐标已存入\"" wjm "\"中"))
)
)
)
(setvar "cmdecho" cm)
(princ)
)
更多追问追答
追问
我想要输出的格式为“123.12,145.23”这样,即不要前面的序号以及最后的逗号,望高手改下你的程序,
追答
(defun c:tqzb (/)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (setq wjm (getfiled "请指定要保存的坐标文件" "e:\\" "txt" 1))
(if (setq ssa (ssget '((0 . "LWPOLYLINE"))))
(progn
(setq fff (open wjm "w")
n (sslength ssa)
i 0
no 0
)
(repeat n
(setq dxf (entget (ssname ssa i))
i (1+ i)
ptb (mapcar 'cdr (vl-remove-if-not '(lambda(x)(= (car x) 10)) dxf))
ptb (mapcar '(lambda(x)(trans x 0 1)) ptb)
)
(foreach pt ptb
(setq no (1+ no))
;(write-line (strcat (itoa no) ","
(rtos (car pt) 2 2) ","
(rtos (cadr pt) 2 2) ","
)
fff
)
)
)
(close fff)
(princ (strcat "\n坐标已存入\"" wjm "\"中"))
)
)
)
(setvar "cmdecho" cm)
(princ)
)
海拉鲁的螃蟹ug
2013-11-05 · TA获得超过419个赞
知道小有建树答主
回答量:247
采纳率:100%
帮助的人:138万
展开全部
源程序呢?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式