- UID
- 215173
- 积分
- 411
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-1-29
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我看到以前的几个文章
一直以来路由程序是一个难点..
好象没有谁写出来过...
呵呵...经过我的一番琢磨...觉得并不是
很难..看..
[PHP]
(defun c:hy_roadway(/ layer sst point1 point2 key p1 PX ssty)
(setvar "cmdecho" 0)
(setvar "osmode" 1)
(setq layer (getvar "clayer"))
(command "undo" "be")
(setq sst '())
(setq point1 (getpoint "\n請選擇路由點1:"))
(while (not (hy_roadway_1 point1))
(setq point1 (getpoint "\n起點無實體重新選路由點1:"))
)
(setq point2 (getpoint "\n請選擇路由點2:"))
(while (not (hy_roadway_1 point2))
(setq point2 (getpoint "\n終點無實體重新選路由點2:"))
)
(setvar "osmode" 0)
(setq key nil)
(setq ent nil)
(setq p1 nil)
(WHILE (not key)
(if (hy_roadway_1 point1)
(progn
(hy_aplinexx (ssname (hy_roadway_1 point1) 0))
(setq pa (vlax-curve-getendpoint (vlax-ename->vla-object (entlast))))
(setq pb (vlax-curve-getstartpoint (vlax-ename->vla-object (entlast))))
(if (not (equal pa point1 0.0001))
(setq px pa) (setq px pb))
(if (equal px point2 0.0001)
(progn
(setq ent (entlast))
(SETQ SST (hy_polyss ENT))
(setq key t)
;(hy_roadway_3 (entlast))
)
(hy_roadway_3 (entlast))
)
)
(setq key t)
)
)
(command "undo" "e")
(command "undo" 1)
(if ent
(progn
(setq io 0)
(setq ssty (ssadd))
(REPEAT (LENGTH SST)
(ENTMAKE (nth io sst))
(command "change" (entlast) "" "p" "color" 1 "")
(setq ssty (ssadd (entlast) ssty))
(setq io (1+ io))
)
(command "pedit" "m" ssty "" "y" "j" 0.0001 "" )
)
(alert "\n此兩點間無路由!")
)
(prin1)
)
(defun hy_roadway_1(point / pt1 ss)
(setq pt1 (polar point 0.8 0.01))
(setq ss (ssget "c" point pt1))
ss
)
(defun hy_roadway_2(en / endata enlist)
(setq endata (entget en))
(setq enlist (member (assoc 10 endata) endata))
(setq enlist (append (list '(0 . "LWPOLYLINE")(cons 8 layer)) enlist))
enlist
)
(defun hy_roadway_3(en / pt1 pt2 ssg)
(command "._explode" en)
(setq ssg (hy_roadway_1 px))
(command "._erase" ssg "")
)
(defun hy_aplinexx(ename1 / vla-obj tux endpoint ename startpoint i ss1 ss5
ss7 ss6 nn ssm ssn itemx);;;選擇一條線串接與之相聯的圖元為多義線
(setvar "osmode" 0)
(if (= "LWPOLYLINE" (cdr(assoc 0 (entget ename1))))
(progn (command "._explode" ename1)
(setq ename (entlast)))
(setq ename ename1)
)
(setq vla-obj (vlax-ename->vla-object ename))
(setq startpoint (vlax-curve-getstartpoint vla-obj)
endpoint (vlax-curve-getendpoint vla-obj))
(setq j 0);;計數器歸0
(setq nn 0)
(princ " ─── \r")
(while (> (distance startpoint endpoint) 0.0000001);(= (vla-get-closed vla-obj) :vlax-false)
(setq ss5 (ssget "C" startpoint (polar startpoint 0.8 0.01)))
(setq ss6 (ssget "C" endpoint (polar endpoint 0.8 0.01)))
(setq ss7 (addss ss5 ss6))
(setq ss7 (ssdel ename ss7))
(setq tux 0)
(repeat (sslength ss7)
(setq ento (entget (ssname ss7 tux)))
(if (and (not (member (list 10 (car startpoint)(cadr startpoint))
ento))
(not (member (list 10 (car endpoint)(cadr endpoint))
ento))
)
(COND ((vlax-curve-getparamatpoint
(vlax-ename->vla-object(ssname ss7 tux)) startpoint)
(command "._break" (ssname ss7 tux) startpoint startpoint))
((vlax-curve-getparamatpoint
(vlax-ename->vla-object(ssname ss7 tux)) endpoint)
(command "._break" (ssname ss7 tux) endpoint endpoint)
)
)
(if (= "LWPOLYLINE" (cdr(assoc 0 ento)))
(command "._explode" (ssname ss7 tux)))
)
(setq tux (1+ tux))
)
(setq ss1 (ssget "C" startpoint (polar startpoint 0.8 0.01)))
(setq ss2 (ssget "C" endpoint (polar endpoint 0.8 0.01)))
(setq ss1 (addss ss1 ss2))
(if (= "LWPOLYLINE" (cdr(assoc 0 (entget ename))))
(command "pedit" ename "j" ss1 "" "")
(command "pedit" ename "y" "j" ss1 "" "")
)
(setq ename (entlast))
(setq vla-obj (vlax-ename->vla-object ename))
(setq startpoint (vlax-curve-getstartpoint vla-obj)
endpoint (vlax-curve-getendpoint vla-obj))
(setq nn (1+ nn))
(cond ((= nn 15)(princ (strcat "線很長..正在串接中,請稍侯 ...... ───" "\r")))
((= nn 30)(princ (strcat "線很長..正在串接中,請稍侯 ...... ﹨﹨﹨" "\r")))
((= nn 45)(princ (strcat "線很長..正在串接中,請稍侯 ...... │││" "\r")))
((= nn 60)(princ (strcat "線很長..正在串接中,請稍侯 ...... ∕∕∕" "\r")))
)
(if (> nn 60) (setq nn 1))
(setq j (1+ j))
(IF (= 1 (sslength ss1))
(setq startpoint '(0 0 0) endpoint '(0 0 0)));(alert "\n請注意!****串接不線不能封閉!")
)
(if (> j 1000)(princ (strcat "\n恭喜你一共把" (itoa (+ (* 2 j) 3)) "條線串接成了一個封閉的復線!")))
)
(defun addss(ss1 ss2 / i );;;將一個選擇集的內容加入另一個,合并選擇集
(setq i 0)
(repeat (sslength ss1)
(setq ss2 (ssadd (ssname ss1 i) ss2))
(setq i (1+ i))
)
(setq ssg ss2)
)
(defun hy_polyss(en / i polist po1 po2 imfor1 centers radi stang edang list1);;該程序實現將復線中所包含的圖元信息加入列表方便以后用ENTMAKE重新建立圖元
(setq polist (ap-polyline-vblist en))
(setq i 0)
(setq elist '())
(repeat (- (length polist) 1)
;(setq list1 '())
(setq po1 (nth i polist))
(setq po2 (nth (1+ i) polist))
(setq imfor1 (ap-polyline-segment po1 po2))
(if (ap-item 'CENTER imfor1)(progn (setq centers (cons 10 (ap-item 'CENTER imfor1))
radi (cons 40 (ap-item 'RADIUS imfor1)))
(if (< (ap-item 'INCLUDED-ANG imfor1) 0)
(setq stang (cons 50 (ap-item 'END-ANG imfor1))
edang (cons 51 (ap-item 'START-ANG imfor1)))
(setq stang (cons 51 (ap-item 'END-ANG imfor1))
edang (cons 50 (ap-item 'START-ANG imfor1)))
)
(setq list1 (list (CONS 0 "ARC") centers radi stang edang))
(setq elist (cons list1 elist))
)
(progn (setq p1 (cons 10 (car po1)) p2 (cons 11 (car po2)))
(setq list1 (list (CONS 0 "LINE") p1 p2))
(setq elist (cons list1 elist))
)
)
(setq i (1+ i))
)
(setq elist (reverse elist))
)
[/PHP] |
|