LISP使用ce复制多段线
你好在阅读了很长一段时间(并从中受益匪浅)之后,我的第一个帖子来了:
我需要一个例程来创建许多具有相同起点的多段线。我厌倦了总是把第一分移回正确的起点。
这是我的解决方案,有点像复制-拉伸混合。这能以更优雅的方式实现吗?
(defun c:cfp ( / i ss plist_o ss_n elist_t plist_t pcount bpoint)
(vl-load-com)
;get points of original polyline
(setq
ss (car(entsel "\nSelect Polyline to copy."))
plist_o (vl-remove-if-not
(function (lambda (pt) (= (car pt) 10)))
(entget ss)
)
)
;get userinput on how many points should be fixed and basepoint for multiple copies
(initget 4)
(setq
pcount (getint "\nHow many points should be fixed? <1>"))
(if (= pcount nil) (setq pcount 1))
(setq bpoint (getpoint "\nSelect basepoint"))
(while (not nil)
;perform copy and get the points of the temporal polyline
(command "_copy" ss "" bpoint pause)
(setq
ss_n (entlast)
elist_t (entget ss_n)
plist_t (vl-remove-if-not
(function (lambda (pt) (= (car pt) 10)))
(entget ss_n)
)
)
;change the fixed points of the temporal polyline back to the
;original points and draw the final polyline
(setq i 0)
(repeat pcount
(setq elist_t
(subst
(nth i plist_o)
(nth i plist_t)
elist_t
)
)
(setq i (1+ i))
)
(entmod elist_t)
)
)
页:
[1]