wanhongron 发表于 2015-8-2 17:07:29

大侠们进来看看,稀疏多段线节点能做到吗?

还是经常用矢量图刻绘,节点太密,想稀疏一下,大概意思是每隔5个节点就删掉4个保留1个,这样刻绘起来下刀没那么密,还请大侠们多多指教!

cable2004 发表于 2015-8-2 18:07:41

(defun c:tt()
   (setq ss (ssget '((0 . "LWPOLYLINE"))))
   (if ss
   (foreach e1 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
   (setq e (entget e1)
         h (reverse (member (assoc 39 e) (reverse e)))
         l (LM:LWVertices e)
         z (assoc 210 e)
         i -1 lst nil)
   (foreach a l (if (= 0 (rem (setq i (1+ i)) 4)) (setq lst (cons a lst))))
   (entmod (append h(apply 'append (reverse lst))(list z)))
))
   (princ)
)
;; LW Vertices-Lee Mac
;; Returns a list of lists in which each sublist describes
;; the position, starting width, ending width and bulge of the
;; vertex of a supplied LWPolyline
(defun LM:LWVertices ( e )
    (if (setq e (member (assoc 10 e) e))
      (cons
            (list
                (assoc 10 e)
                (assoc 40 e)
                (assoc 41 e)
                (assoc 42 e)
            )
            (LM:LWVertices (cdr e))
)))

(vl-load-com) (princ)

wanhongron 发表于 2015-8-2 23:33:40

cable2004侠真是好人,每次提问题都帮热心解决,小妹无以为报,感激不尽!!!

wanhongron 发表于 2015-8-2 23:35:19

鲜花赠大侠!

wanhongron 发表于 2015-8-11 22:27:13

各位大侠,还有个小小的建议,按这个程序有可能会出现最后的端点被删除,如多段线有12个端点,每隔4个删除1个,那么最后1个刚好就被删除了,能增加一个判断保证最后的端点不被删除吗?

wanhongron 发表于 2015-8-13 09:04:57

还是要烦请cable2004侠出马。。

hmseu 发表于 2019-12-23 15:42:10

谢谢cable2004

qazxswk 发表于 2022-3-30 01:20:43

cable2004 发表于 2015-8-2 18:07


这个效率很高呀。
页: [1]
查看完整版本: 大侠们进来看看,稀疏多段线节点能做到吗?