多段线坐标TXT输出坐标 求高手帮助
(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
no0
)
(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 (carpt) 2 2) ","
(rtos (cadr pt) 2 2) ","
)
fff
)
)
)
(close fff)
(princ (strcat "\n坐标已存入\"" wjm "\"中"))
)
)
)
(setvar "cmdecho" cm)
(princ)
)
输出的坐标小数点是两位怎么能修改成小数点后三位或者四位?
(rtos (carpt) 2 2) ","
(rtos (cadr pt) 2 2) ","
改成
(rtos (carpt) 2 3) ","
(rtos (cadr pt) 2 3) ","
就好了吧 903242237 发表于 2015-7-29 09:00 static/image/common/back.gif
(rtos (carpt) 2 2) ","
(rtos (cadr pt) 2 2) ","
改成
谢谢问题已经解决 呵呵. 请教下 没有基础 我想学习下LSP程序 编程 看点什么书? 有直接定义好保存的文件位置和文件名的吗,不想在过程中还要指定一下文件名 能在图中增加顶点编号功能吗? 本帖最后由 lee50310 于 2022-4-26 19:11 编辑
wanhongron 发表于 2022-4-26 12:54
能在图中增加顶点编号功能吗?
你是指這功能嗎?
本帖最后由 song宋_74729 于 2022-4-26 19:34 编辑
(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
no0
)
(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 (carpt) 2 3) ","
(rtos (cadr pt) 2 3) ","
)
fff
)
)
)
(close fff)
(princ (strcat "\n坐标已存入\"" wjm"\"中"))
)
)
)
(setvar "cmdecho" cm)
(princ)
)
小数点后三位
(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
no0
)
(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 (carpt) 2 4) ","
(rtos (cadr pt) 2 4) ","
)
fff
)
)
)
(close fff)
(princ (strcat "\n坐标已存入\"" wjm"\"中"))
)
)
)
(setvar "cmdecho" cm)
(princ)
)
小数点后四位 纯小白,请问cad提示 输入的字符串有缺陷,怎么办
页:
[1]