求助G版,问过N个人了,都没有解决办法,希望G版出手帮忙提供思路
本帖最后由 jxjaxa 于 2012-6-2 01:04 编辑假设图中有4个点,其中有两个点是起点 和 终点 ,而且起点 和终点是固定的,请问G版如何将图中所有路径求出。
帮顶,谢谢大佬完美解决 大家帮忙顶一下行么 (defun aaa (ps p1 p2 pe mode)
(cond ((= mode 1) (xyp-Entmake-lwPolyline (list ps pe) nil))
((= mode 2) (xyp-Entmake-lwPolyline (list ps p1 pe) nil))
((= mode 3) (xyp-Entmake-lwPolyline (list ps p2 pe) nil))
((= mode 4) (xyp-Entmake-lwPolyline (list ps p1 p2 pe) nil))
((= mode 5) (xyp-Entmake-lwPolyline (list ps p2 p1 pe) nil))
)
)
xyp1964 发表于 2012-6-2 10:12 static/image/common/back.gif
谢谢院长 ,N个点 ,此方法不适应,需院长 大 人 继续出招,谢过 jxjaxa 发表于 2012-6-2 10:23 static/image/common/back.gif
谢谢院长 ,N个点 ,此方法不适应,需院长 大 人 继续出招,谢过
谢谢G版,您终于出现了,您再细说一下行么 院长顶您,顶出源码 xyp1964 发表于 2012-6-2 23:51 static/image/common/back.gif
院长给我学习一下行么 看看这个思路:
1.确定起点,终点
2.遍历所有的点,计算与起点最近的(点2)
3.过滤掉(点2),.....循环计算至终点完成循环.
4.这条线路应该是最优化的,再循环可得所有的线路
这个很容易的,以下例子原理一样,可以作为参考...
;快速连线
(defun kslx3 (/ j k sm dx dxty kslsh x-1 y-1 j-2 k-2 sm-2 dx-2 dxty-2 kslsh x-2 y-2 dx-lr-2 j-rl k-rl sm-rl dx-rl j-rl-text zcd-sss zds-xxx)
(command "setvar" "PDMODE" 2) ;设置点样式= "+" 高度= 1
(command "setvar" "PDSIZE" 1)
(SETVAR "OSMODE" 0)
(command "zoom" "e")
(setq j2 (ssget "x" '((-4 . "<and") (8 . "ZDH") (0 . "POINT") (62 . 7) (-4 . "and>"))))
(if j2
(progn
(setq k2 0 sm2 (sslength j2))
(while (< k2 sm2)
(setq dx2 (ssname j2 k2))
(setq dxty2 (entget dx2))
(setq tc3 (assoc 62 dxty2))
(setq tc4 (cons 62 1))
(entmod (subst tc4 tc3 dxty2))
(setq k2 (+ k2 1)) )
(setq j2 nil) ))
;;;;;;;;;;;;;;;;;;;;;dell 已有的line
(setq j-rl (ssget "x" '((-4 . "<and") (8 . "RL") (0 . "line") (-4 . "and>"))))
(if j-rl
(progn
(setq k-rl 0 sm-rl (sslength j-rl))
(while (< k-rl sm-rl)
(setq dx-rl (ssname j-rl k-rl))
(command "erase" dx-rl "")
(setq k-rl (+ k-rl 1)) ) ))
;;;;;;;;;;;;;;;;;;;;;dell 已有的line
(setq j-rl-text (ssget "x" '((-4 . "<and") (8 . "ZDH") (0 . "POINT") (-4 . "and>"))))
(if j-rl-text
(progn
(setq zcd-sss 0 zds-xxx 0)
(command "-layer" "m" "RL" "c" "6" "" "")
(setq j (ssget "x" '((-4 . "<and") (8 . "ZDH") (0 . "POINT") (-4 . "and>"))))
(setq k 0 sm (sslength j))
(while (< k sm)
(setq dx (ssname j k))
(setq dxty (entget dx '("*")))
(setq lr3 (cdr (cadadr (assoc -3 dxty))))
(if (and (/= (substr lr3 1 1) "B") (/= (substr lr3 1 1) "G")(/= (substr lr3 1 1) "g")
(or (= (substr lr3 1 1) "r") (=(substr lr3 1 1) "R")) )
(PROGN
(setq kslsh (atoi (substr lr3 2 100)))
(setq x-1 (nth 1 (assoc 10 dxty)) y-1 (nth 2 (assoc 10 dxty)) z-1 (nth 3 (assoc 10 dxty)))
(setq j-2 (ssget "x" '((-4 . "<and") (8 . "ZDH") (0 . "POINT") (-4 . "and>"))))
(setq k-2 0 sm-2 (sslength j-2))
(while (< k-2 sm-2)
(setq dx-2 (ssname j-2 k-2))
(setq dxty-2 (entget dx-2'("*")))
(setq dx-lr-2 (atoi (substr (cdr (cadadr (assoc -3 dxty-2))) 2 100)))
(if (= dx-lr-2 (+ kslsh 1))
(progn
(SETQ x-2(nth 1 (assoc 10 dxty-2)) y-2 (nth 2 (assoc 10 dxty-2)) z-2 (nth 3 (assoc 10 dxty-2)))
(command "line" (list x-1 y-1 z-1) (list x-2 y-2 z-2) "")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq pp1 (list x-1 y-1 z-1) pp2 (list x-2 y-2 z-2))
(setq sss (distance pp1 pp2))
(setq zcd-sss (+ zcd-sss sss))
(setq zds-xxx (+ zds-xxx 1))
(princ (strcat "\n编码=" (rtos kslsh 2 0) " 起点桩号编码= " (rtos kslsh 2 0) " 止桩号编码= " (rtos dx-lr-2 2 0) " 长度= " (rtos sss)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq k-2 sm-2)))
(setq k-2 (+ k-2 1))) ))
(setq k (+ k 1)))
(command "-layer" "m" "0" "")
(princ (strcat "\n管线点总数= " (rtos (sslength j-rl-text) 2 0) " 个"))
(princ (strcat "\n连线总段数= " (rtos zds-xxx 2 0) " 段"))
(princ (strcat "\n 总长度= " (rtos zcd-sss 2 2) " 米")) )
(princ "\n 没有找到 ZDH图层的TEXT") )
(setq j-rl nil)
(setq j nil)
;;;;;;;;;;;;;;
(if (= zds-xxx (- (sslength j-rl-text) 1))
(progn
(speek "OK")
(alert "\n RTK成果处理已通过 ")))
;;;;;;;;;;;;;;
(setq j-rl-text nil)
(princ)
) 这个难度要大一点,因为要按流水号
页:
[1]
2