导出圆心坐标
本帖最后由 iszc 于 2014-10-18 08:22 编辑有什么方法能导出框选区域内所有圆的圆心坐标,大约框选100个左右,位置按照上下左右的顺序提取 不错的帖子 顶一下 ssget 过滤圆 框选的已经是所有的圆,没有其他,求导出或列出所有圆心坐标,能帮忙写一个lsp么 未能搜到 本帖最后由 wmz 于 2014-10-18 21:22 编辑
(defun c:tt()
(setq f (open "D:/test.txt" "w"))
(setq s (ssget))
(setq n (sslength s) m 0 pp '())
(repeat n
(setq e (ssname s m) m (1+ m))
(setq e1 (entget e))
(setq e2 (cdr(assoc 0 e1)))
(if (= e2 "CIRCLE")
(progn
(setq pt (cdr (assoc 10 e1)))
(setq pp (cons pt pp))
)
)
)
(setq pp (vl-sort pp
(function (lambda (a b)
(if (= (car a) (car b))
(<= (car a) (car b))
(> (cadr a) (cadr b))
)
)
)
)
)
(setq m 0)
(repeat (length pp)
(setq p (nth m pp) m (1+ m))
(setq y (car p) x (cadr p))
(setq b (strcat (rtos m 2 0) "," (rtos y 2 2) "," (rtos x 2 2)))
(write-line b f)
)
(close f)
(princ)
) 只能选中,不能导出坐标 非常感谢 ZZXXQQ 能帮忙
很满意,不知怎么改精度为小数点后4位,如果要累加在D:\test.txt能做到么 Ref Rtos 的帮助 排序有点问题,测试结果:
-------------------------------------
1,54.92,-2.62
2,131.76,-2.62
3,83.49,-28.74
4,142.67,-28.74
5,114.62,-52.02
6,59.37,-52.02
7,77.79,-52.02
8,96.20,-52.02
9,133.03,-52.02
10,38.16,-55.20
11,123.88,-76.57
12,34.73,-78.86 sicky111 发表于 2014-10-19 12:56 static/image/common/back.gif
排序有点问题,测试结果:
-------------------------------------
1,54.92,-2.62
(setq pp (vl-sort pp
(function (lambda (a b)
(if (= (cadr a) (cadr b))
(<= (car a) (car b))
(> (cadr a) (cadr b))
)
)
)
)
)