xxzwtr 发表于 2011-5-11 23:56:17

悬赏1明经币求枝状线路遍历求各路长度LSP源码!!!

如下图怎样求出每一路径长度???求高手源码.!!!


198526 发表于 2011-5-12 08:04:46

把DWG文件放上来

xxzwtr 发表于 2011-5-13 23:19:50

悬赏1明经币求枝状线路遍历求各路长度LSP源码!!! [

yarp 发表于 2011-5-17 15:00:27

道先请把你的lwpolyline转换为line
把代码贴出如下:

(defun search:pathSearch
       (startPoint path tobesearch / line entity otherPoint found)
(setq found nil)
(foreach line        tobesearch
    (if        line
      (progn
        (setq entity (entget line))
        (if
          (search:point-eq startPoint (assoc 10 entity))
           (progn
             (setq otherPoint (assoc 11 entity))
             (setq path (append path (list otherPoint)))
             (search:pathSearch
             otherPoint
             path
             (subst nil line tobesearch)
             )
             (setq found t)
           )
        )
        (if
          (search:point-eq startPoint (assoc 11 entity))
           (progn
             (setq otherPoint (assoc 10 entity))
             (setq path (append path (list otherPoint)))
             (search:pathSearch
             otherPoint
             path
             (subst nil line tobesearch)
             )
             (setq found t)
           )
        )
      )
    )
    )
    (if        (not found)
      (search:printPath path)
    )
)




(defun search:point-eq (apoint bpoint / val)
    (if (and
        (= (cadr apoint) (cadr bpoint))
        (= (caddr apoint) (caddr bpoint))
        (= (cadddr apoint) (cadddr bpoint))
      )
    (setq val T)
    (setq val NIL)
)
)

(defun search:printPath (path / prev point leng)
(setq prev nil leng 0.0)
(princ "\n 路径是")
(foreach point path
    (princ "\t")
    (princ (cdr point))
    (if prev
      (setq leng (+ leng (distance (cdr prev) (cdr point))))
      )
    (setq prev point))
(princ "\n 总长度是")
(princ leng)
)

(defun c:pathSearch (/ point lines all)
(setq point (cons 10 (getpoint "\n选择起点")))
(princ "\n 选择所有路径直线")
(setq all (ssget))
(setq len (sslength all))
(setq cur 0)
(while (> (- len cur) 0)
    (setq name (ssname all cur))
    (setq cur (+ 1 cur))
    (if        (= (cdr (assoc 0 (entget name))) "LINE")
      (setq lines (append (list name) lines))
    )
)
(search:pathSearch point '() lines )
(princ)
)

xxzwtr 发表于 2011-5-18 23:25:38

真高手也
很强大,非常强大

xxzwtr 发表于 2011-5-18 23:48:02

能留个联系方式否?

xxzwtr 发表于 2011-5-19 00:32:24

回复 yarp 的帖子

能留个联系方式否,有些问题请教,及有些事情商量。

yarp 发表于 2011-5-19 09:07:12

QQ 406695843
Email yarp@sohu.com

cjjh8301 发表于 2011-6-2 20:23:09

问题解决了,就请选择最佳答案,在给你解决问题那楼的右下角。

434939575 发表于 2011-9-12 22:37:50

高手。学习了
页: [1]
查看完整版本: 悬赏1明经币求枝状线路遍历求各路长度LSP源码!!!