明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1487|回复: 10

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

[复制链接]
发表于 2011-5-11 23:56 | 显示全部楼层 |阅读模式
1明经币
如下图怎样求出每一路径长度???求高手源码.!!!


附件: 您需要 登录 才可以下载或查看,没有账号?注册
发表于 2011-5-12 08:04 | 显示全部楼层
把DWG文件放上来
回复

使用道具 举报

 楼主| 发表于 2011-5-13 23:19 | 显示全部楼层
悬赏1明经币求枝状线路遍历求各路长度LSP源码!!! [

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
回复

使用道具 举报

发表于 2011-5-17 15:00 | 显示全部楼层
道先请把你的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)
)
回复

使用道具 举报

 楼主| 发表于 2011-5-18 23:25 | 显示全部楼层
真高手也
很强大,非常强大
回复

使用道具 举报

 楼主| 发表于 2011-5-18 23:48 | 显示全部楼层
能留个联系方式否?
回复

使用道具 举报

 楼主| 发表于 2011-5-19 00:32 | 显示全部楼层
回复 yarp 的帖子

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

使用道具 举报

发表于 2011-5-19 09:07 | 显示全部楼层
QQ 406695843
Email yarp@sohu.com
回复

使用道具 举报

发表于 2011-6-2 20:23 | 显示全部楼层
问题解决了,就请选择最佳答案,在给你解决问题那楼的右下角。
回复

使用道具 举报

发表于 2011-9-12 22:37 | 显示全部楼层
高手。学习了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 13:05 , Processed in 0.251911 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表