该lisp获取每条线,并绘制一条新线,通过bowditch(或指南针规则)计算,以使终点坐标与起点坐标相同。它在线路末端找到任何块,并将其移动到新的校正位置。我附上了一个带有导线测量粗略示例的dwg。显然,要调整的导线是回路或回路中的线,您需要按顺序从头到尾进行选择。
- (defun c:adj3 (/ mis sset tot num itm totdis<p>hnd ent dis indx lobj disa dist)</p><p>(setq oldcmd (getvar "cmdecho"))</p><p>(setvar "cmdecho" 0)</p><p>(setvar "osnapcoord" 1)</p><p>(command "._layer" "_M" "Misclose" "")</p><p>(command "._layer" "_C" "2" "Misclose" "")</p><p>(setvar "clayer" "Misclose")</p><p>(setq p1 (getpoint "n\Pick unadjusted end of Traverse")</p><p>p2 (getpoint "n\Pick closing point"))</p><p>(command "line" p1 p2 "")</p><p>(setq mis (entlast))</p><p>(setq sset (ssget '((0 . "LINE"))))</p><p>(if sset</p><p>(progn</p><p>(setq tot 0.0)</p><p>(setq num (sslength sset) itm 0)</p><p>(repeat num</p><p>(while (</p><p>(setq hnd (ssname sset itm))</p><p>(setq ent (entget hnd))</p><p>(setq pt1 (cdr (assoc 10 ent)))</p><p>(setq pt2 (cdr (assoc 11 ent)))</p><p>(setq dis (distance pt1 pt2))</p><p>(setq tot (+ tot dis))</p><p>(setq itm (1+ itm))</p><p>)</p><p>)))</p><p>(if (= itm num) (setq totdis tot))</p><p>(if totdis</p><p>(progn</p><p>(setq tot 0.0)</p><p>(setq len (sslength sset) indx 0)</p><p>(while (</p><p>(setq lobj (ssname sset indx))</p><p>(setq objd (entget lobj))</p><p>(setq pt1 (cdr (assoc 10 objd)))</p><p>(setq pt2 (cdr (assoc 11 objd)))</p><p>(if (> indx 0) (setq pl1 pl2))</p><p>(setq dis (distance pt1 pt2))</p><p>(setq tot (+ tot dis))</p><p>(command ".erase" objd "")</p><p>(command "._copy" mis "" p1 pt2)</p><p>(setq obj (entlast))</p><p>(setq disa (distance p1 p2))</p><p>(setq dist (* (/ tot totdis) disa))</p><p>(command "._scale" obj "" pt2 "r" p1 p2 "P" dist)</p><p>(command "._layer" "_M" "Traverse Adjusted" "")</p><p>(command "._layer" "_C" "1" "Traverse Adjusted" "")</p><p>(setvar "clayer" "Traverse Adjusted")</p><p>(setq pl2 (cdr (assoc 11 (entget obj))))</p><p>(if (= indx 0) (command "._line" pt1 pl2 ""))</p><p>(if (> indx 0) (command "._line" pl1 pl2 ""))</p><p>(setq ins (ssget "_X" (list '(-4 . "=,=,*")(cons 10 pt2)(cons 0 "insert"))))</p><p>(command "._move" ins "" pt2 Pl2)</p><p>(if (> indx 0) (progn</p><p>(setq rad (ssget "_X" (list '(-4 . "=,=,*")(cons 10 pt1)(cons 0 "LINE"))))</p><p>(command "._move" rad "" pt1 pl1)))</p><p>(command ".erase" obj "")</p><p>(setq indx (1+ indx))</p><p>)</p><p>)</p><p>)</p><p>(command ".erase" mis "")</p><p>(princ)</p><p>)[code]</p><p> </p><p> </p><p>Now the problem.. I want to shift any lines that radiate from pnt 2 and that are not in the adjusted circuit to the same new position. </p><p> </p><p>How can I assess anymore continuing lines and blocks starting from the ends of these radiations and shift them with the radiation? Possible? </p><p> </p><p>maybe something like..if radiation exist get, assoc 11, and if block or radiation exist at endpoint include in radiation set loop until nothing then continue with rest of program.??!!</p><p>Bowditch.dwg</p>
|