悬赏1明经币求枝状线路遍历求各路长度LSP源码!!!
如下图怎样求出每一路径长度???求高手源码.!!!把DWG文件放上来 悬赏1明经币求枝状线路遍历求各路长度LSP源码!!! [ 道先请把你的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)
) 真高手也
很强大,非常强大 能留个联系方式否?
回复 yarp 的帖子
能留个联系方式否,有些问题请教,及有些事情商量。 QQ 406695843
Email yarp@sohu.com 问题解决了,就请选择最佳答案,在给你解决问题那楼的右下角。 高手。学习了
页:
[1]