明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1463|回复: 2

一个问题,不得其解了,请帮忙看下

[复制链接]
发表于 2005-1-23 11:04:00 | 显示全部楼层 |阅读模式
我想在一条线上(由多条line,pline组成)选中一段线,自动找出整条线,用红色显示,该线的各线段名称(ename)保存在mline的列表中,我判断的时候将已经找出的线段排除了(itemexist 判断),可是结果还是会重复已经找出的线段,请各位看看这是哪里错了,3ks!
发表于 2005-1-23 11:23:00 | 显示全部楼层
贴出你的程序段,别人才好判断。
 楼主| 发表于 2005-1-24 10:30:00 | 显示全部楼层
本来上传了的,现在写在下面,帮忙看下:),主程序是findline (defun ptinpl (ename n)
(setq ent (entget ename))
(setq i (+ 14 (* (- n 1) 4)))
(cdr (nth i ent))
;(list (nth (* n 2) plist)(nth (1+ (* n 2)) plist))
) (defun ptnofpl(ename)
(setq ent (entget ename))
(/ (- (length ent) 15) 4)
) (defun itemexist(mlist item / bu len i)
(setq bu nil)
(setq len (length mlist) i (- len 1))
(while (>= i 0)
(if (= (nth i mlist) item) (setq bu t i 0))
(setq i (- i 1))
)
bu
)


(defun c:findline()
(setq lstart nil) ;;line name list
(while (not lstart)
(setq lstart (car (entsel "\n选择线的起始线:")))
)
(setq ltype (cdr (assoc 0 (entget lstart))))
(if (= (strcase ltype) "LINE")
(setq pt1 (cdr (assoc 10 (entget lstart))) pt2 (cdr (assoc 11 (entget lstart))))
(setq pt1 (ptinpl lstart 1) pt2 (ptinpl lstart (ptnofpl lstart)))
)
(setq ssl (ssget "x" (list (cons 0 "line"))))
(setq sspl (ssget "x" (list (cons 0 "LWPOLYLINE"))))
(setq lno (sslength ssl))
(setq plno (sslength sspl))
(setq num (+ lno plno))
(setq isend nil)
(setq mline (list lstart)) (setq count 0)
(while (not isend)
(setq i 0 isend t)
(while (< i num)
(if (< i lno)
(setq ename (ssname ssl i))
(setq ename (ssname sspl (- i lno)))
)
(if (not (itemexist mline ename))(progn
(setq ent (entget ename))
(setq ltype (cdr (assoc 0 ent)))
(if (< i lno)
(setq tpt1 (cdr (assoc 10 ent)) tpt2 (cdr (assoc 11 ent)))
(setq tpt1 (ptinpl ename 1) tpt2 (ptinpl ename (ptnofpl ename)))
)
(if (= (distance tpt1 pt2) 0)
(progn
(setq mline (append mline (list ename)))
(setq pt2 tpt2 isend nil i num)
)
(if (= (distance tpt1 pt1) 0)
(progn
(setq mline (append mline (list ename)))
(setq pt1 tpt2 isend nil i num)
)
)
)
(if isend
(progn
(if (= (distance tpt2 pt1) 0)
(progn
(setq mline (append mline (list ename)))
(setq pt1 tpt1 isend nil i num)
)
(if (= (distance tpt2 pt2) 0)
(progn
(setq mline (append mline (list ename)))
(setq pt2 tpt1 isend nil i num)
)
)
)))
))
(setq i (+ i 1))
)
(setq count (+ count 1))
(if (>= count 20)(setq isend t))
) (foreach i mline
(command "change" i "" "p" "c" "1" "")
)
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-9-29 20:35 , Processed in 0.170024 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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