Lisp将多线转换为s
你好我正在寻找一个lisp,可以将多行转换为一个单PLINE。
我在附件中找到的将同一多行转换为2 PLINE的lisp
但我需要多条线连接到一条线,而不是两条线。
如果有人有任何想法,请与我分享。。。
:) 最终结果是一条多段线,其宽度模拟了两条多线之间的距离? 可根据图纸进行更改。。
假设MLINE表示管道,则管道直径应不同。。。 注意,我没有指定“set”宽度。所以基本上我的问题的答案是“是的”。对的
希望你抓住我。。。。 备注看起来像mline的原始中心线,不确定mline的“co ords”给出了什么,也需要检查顶部、底部和零。
; converts mline to pline note uses mline vertices does not take
; into account top or bottom offset
; By Alan H Aug 2017
(defun c:test ( / co-ords ent co-ordsxy xy oldsnap)
(setq oldsnap (getvar "osmode"))
(setq ss (ssget (list (cons 0 "Mline")))) ; pick only mlines
(if (/= ss nil)
(progn
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (- x 1)))) ; get mlines
(setq co-ords
(vlax-safearray->list
(vlax-variant-value
(vlax-get-property
(vlax-ename->vla-object ent) ; get co-ordinates of mline
"Coordinates"
)
)
)
)
; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z
(setq numb (/ (length co-ords) 3)) ; mlines have a z value hence / 3
(setq I 0)
(repeat numb
(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
(setq co-ordsxy (cons xy co-ordsxy)) ; make a list of co-ordinates
(setq I (+ I 3))
)
(setvar "osmode" 0)
(command "_pline")
(while (= (getvar "cmdactive") 1 )
(repeat (setq y (length co-ordsxy))
(command (nth (setq y (- y 1)) co-ordsxy)) ; read list of points
)
(command "")
)
(setq co-ordsxy nil) ; reset to do again
(command "erase" ent "")
)
)
)
(setvar "osmode" oldsnap) ; reset snap mode
)
比加尔,
那太棒了,相当不错。
仍然存在一个问题。。。。。
1.MLINE仍然存在(需要删除的MLINE)
2、新创建的PLINE不是MLINE的中心线。(在这种情况下,我将多线的塞纳线视为一条普林线,基础多线应替换为新普林线)
希望你能满足我的要求。:) 删除添加到代码,顶部或底部使其更难。 无论如何,多线包含奇数,如3,5,7,9。。。。等Mlines,它将以中心线作为PLINE。(但不是偶数)。
正如您所提到的,如果删除更难添加,那么easly可以通过带有“选择类似”选项的Erase命令删除保留多行。
谢谢大家的大力支持:D:D:D 我已经将您的帖子转移到AutoLISP、Visual LISP和DCL论坛。
页:
[1]
2