c3a139 发表于 2008-11-24 15:48:00

line合成为pline

<p>下面的程序是把LINE合成PLINE的,但运行起来速度较慢,如何能改进?有2222个对象,完成需要约30秒</p><p>(defun l2pl (/ SS1) <br/>&nbsp; (vl-load-com) <br/>&nbsp; (vl-cmdf ".undo" "BE") ;开始<br/>&nbsp; (setq ss1 (ssget "X" <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (list<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (cons 0&nbsp; "LINE") <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (cons 6&nbsp; "CONTINUOUS") <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (cons -4&nbsp; "&lt;&gt;,*,*") <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (list 10 1.25 0 0)<br/>&nbsp;&nbsp;&nbsp; (cons -4&nbsp; "&lt;&gt;,*,*") <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (list 10 -1.25 0 0)<br/>&nbsp;&nbsp;&nbsp; (cons -4&nbsp; "&lt;&gt;,*,*")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (list 11 1.25 0 0)<br/>&nbsp;&nbsp;&nbsp; (cons -4&nbsp; "&lt;&gt;,*,*")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (list 11 -1.25 0 0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ) <br/>&nbsp; )&nbsp;&nbsp; <br/>&nbsp; (if (/= ss1 nil) <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (command "_.PEDIT" "M" ss1 "" "Y" "J" "0" "") <br/>&nbsp; ) <br/>&nbsp; (vl-cmdf ".undo" "E") ;结束<br/>&nbsp; (princ) <br/>) </p>

cnks 发表于 2008-11-24 15:54:00

<p>pe就搞定的编程太浪费了</p>

Alan.Shi 发表于 2008-11-24 16:32:00

<p>我一直用这个,选一次就搞定</p><p>(defun c:J&nbsp;(/ ped)<br/>&nbsp; (setq ped (getvar "peditaccept"))<br/>&nbsp; (setvar "peditaccept" 1)<br/>&nbsp; (command "pedit" pause "j" "all" "" "")<br/>&nbsp; (setvar "peditaccept" ped)<br/>&nbsp; (princ)<br/>)</p>

c3a139 发表于 2008-11-24 18:31:00

<p>其实咱仨用的都是PE,我的也是一次搞定,只是对象一多,感觉速度有点慢,不知有没有更好的方法</p>

my_autocad 发表于 2008-11-25 20:00:00

<p>;************************************************将所有line变成闭合多义线<br/>(defun c:ple (/ ssa ssa-ent ent-p i)<br/>(command "undo" "be");设置返回起始点<br/>(setq ssa (ssget))<br/>(setq i 0)<br/>(while (&lt; i (sslength ssa))<br/>(setq ssa-ent (ssname ssa i))<br/>(setq ent-p (cdr(assoc 0 (entget ssa-ent))))<br/>(if (not (null ent-p));判断原图元是否已串入多义线<br/>(if (or (= ent-p "LWPOLYLINE") (= ent-p "POLYLINE"));判断原图元属性<br/>(command "pedit" ssa-ent "j" ssa "" "")<br/>(command "pedit" ssa-ent "y" "j" ssa "" "")<br/>))<br/>(setq i (1+ i))<br/>)<br/>(command "undo" "e");设置返回终止点<br/>(princ)<br/>);defun</p><p></p><p>这个程序也挺好用,但是如果两条线没有连接,就合并不了,有什么办法解决没有呢</p>

yitian519 发表于 2008-11-25 23:55:00

不错,学习中。。。

c3a139 发表于 2008-11-27 12:52:00

<p>&nbsp;但是如果两条线没有连接,就合并不了,有什么办法解决没有呢</p><p>(command "_.PEDIT" "M" ss1 "" "Y" "J" "0" "") 把0给一个合适的值如1,在此范围内的就可以合并<br/></p>

my_autocad 发表于 2008-11-27 19:41:00

<p>选择对象: 指定对角点: 找到 2 个<br/>选择对象:<br/>*无效选择*<br/>需要点或 <br/>窗口(W)/上一个(L)/窗交(C)/框(BOX)/全部(ALL)/栏选(F)/圈围(WP)/圈交(CP)/编组(G)/类<br/>(CL)<br/>函数被取消<br/>选择对象:<br/>是否将直线和圆弧转换为多段线?[是(Y)/否(N)]? &lt;Y&gt; *取消*<br/>选择多段线或 [多条(M)]:<br/>选择多段线或 [多条(M)]: *取消*</p><p>(command "_.PEDIT" "M" ss1 "" "Y" "J" "0" "") 把0给一个合适的值如1,在此范围内的就可以合并</p><p>有上面的错误提示,怎么办呢?</p><p></p>

c3a139 发表于 2008-11-29 16:34:00

我试了没有出现你这种情况,你再试试

carrot1983 发表于 2008-11-29 19:46:00

(setvar "peditaccept" 1)
页: [1]
查看完整版本: line合成为pline