明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 9238|回复: 11

[原创]带提示和过滤表的entsel

    [复制链接]
发表于 2003-11-14 08:42 | 显示全部楼层 |阅读模式
功能:类似于(entsel)函数,带提示,且带一个过滤表,只选择表中类型
例子:(sel '("LINE" "LWPOLYLINE") "选择直线...")
返回:同(entsel)一样,(对象名 选择点)


  1. (defun Sel (_types msg / gr ent m ty)
  2.   (defun com(ty tylst / i rVal)
  3.     (setq i 0)
  4.     (while (< i (length tylst))
  5.       (if (= ty (nth i tylst))
  6.         (progn (setq rVal t) (setq i (length tylst)))
  7.       )
  8.       (setq i (1+ i))
  9.     )
  10.     rVal
  11.   )
  12.   (prompt msg)
  13.   (setq m nil)
  14.   (while (not m)
  15.     (setq gr (grread 2 4 2))
  16.     (cond
  17.       ((= (car gr) 3)
  18.        (setq ent (ssget (cadr gr)))
  19.        (if (not (and ent (com (cdr (assoc 0 (entget (setq ent (ssname  ent 0))))) _types)))
  20.          
  21.          (setq ent nil)
  22.        )
  23.        (setq m t)
  24.       )
  25.       ((= (car gr) 25) (setq m t))
  26.     )
  27.   )
  28.   (princ "\n")
  29.   (if ent (list ent (cadr gr)) nil)
  30. )

发表于 2003-11-14 10:14 | 显示全部楼层
這個應該做到, 如果選錯了要返回重新選嘛.   這樣就更好了
 楼主| 发表于 2003-11-14 14:24 | 显示全部楼层
(entsel)选错了能返回重新选吗?我这个函数说了就是类似entsel的,不要总是挑这挑那,你也会编程,有要求为什么不自己写一个?
发表于 2003-11-26 17:03 | 显示全部楼层

  1. ;;BY 龙龙仔(LUCAS)
  2. ;;USAGE:(ENTSEL_LAI "\n选择直线或圆..." '((0 . "*LINE,CIRCLE")))
  3. (defun ENTSEL_LAI (MSG FILTER / SS SSS)
  4.   ;;(while (not SS)
  5.   (setq SS (entsel MSG))
  6.   (if (/= SS NIL)
  7.     (progn
  8.       (command "_.SELECT" (car SS) "")
  9.       (if (not (setq SSS (ssget "P" FILTER)))
  10.         (setq SS NIL)
  11.         (list (ssname SSS 0) (cadr SS))
  12.       )
  13.     )
  14.   )
  15.   ;;)
  16. )

  17. ;;USAGE:(ENTSEL_MSG_FILTER "\n选取POLYINE对象: " '((0 . "LWPolyline")))
  18. (defun ENTSEL_MSG_FILTER (MSG FILTER / SSPICK PICKOBJ PT1)
  19.   (prompt MSG)
  20.   (setq SSPICK (ssget ":S" FILTER))
  21.   (if SSPICK
  22.     (progn
  23.       (setq PICKOBJ (car (ssnamex SSPICK 0)))
  24.       (setq PT1 (cadr (nth 3 PICKOBJ)))
  25.       (list (nth 1 PICKOBJ) PT1)
  26.     )
  27.   )
  28. )

发表于 2004-1-19 22:24 | 显示全部楼层
程序不错!!
发表于 2004-1-24 05:59 | 显示全部楼层
本帖最后由 作者 于 2004-1-28 14:13:44 编辑

不用写那么多行
  1. ;;(xentsel) = 带提示和过滤表的entsel (ssget "p" f)方法.精简代码!---------------------------------------------BY 无痕
  2. ;;调用:(XENTSEL "\n选择直线或圆..." '((0 . "*LINE,CIRCLE")))
  3. ;;循环选则直到选中符合过滤的实体为止(defun xentsel (msg filter)
  4.    (while (not (and (setq el (entsel msg)) (ssget "p" filter))))
  5.    el
  6. );;调用:(XENTSEL1 "\n选择直线或圆..." '((0 . "*LINE,CIRCLE")))
  7. ;;只选一次,返回点表 (实体名 . 点位);选不中或空选返回nil.(defun xentsel1 (msg filter)
  8.    (if (and (setq el (entsel msg)) (ssget "p" filter)) el nil)
  9. )

评分

参与人数 1威望 +1 金钱 +10 贡献 +5 激情 +5 收起 理由
mccad + 1 + 10 + 5 + 5 【精华】好程序

查看全部评分

发表于 2004-10-10 12:02 | 显示全部楼层
xie xie
发表于 2004-11-15 20:45 | 显示全部楼层
无痕发表于2004-1-24 5:59:00不用写那么多行 ;;(xentsel) = 带提示和过滤表的entsel (ssget \"p\" f)方法.精简代码!---------------------------------------------BY 无痕
无痕大侠,我在用xentsel函数时出了点问题 1.我用(setq p (xentsel "\n选择需修改的标注 :" '((0 . "DIMENSION"))))这句时,无法返回结果 2.我用(XENTSEL "\n选择直线或圆..." '((0 . "*LINE,CIRCLE")))选择标注时却可以返回标注的DXF 据我分析应该是entsel选择后并不记录为“最近的选择集”,及“p”对其无效……
发表于 2004-11-16 13:02 | 显示全部楼层
(defun XENTSEL (MSG FILTER)
(while (not (and (setq EL (entsel MSG))
(progn (command "_.select" (car EL) "")
(ssget "p" FILTER)
)
)
)
)
EL
)
发表于 2004-11-16 22:06 | 显示全部楼层
(defun xentsel (msg filter)
(while (not (and (setq el (entsel msg)) (ssget (cadr el) filter))))
el
)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-26 00:03 , Processed in 1.544009 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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