smartstar 发表于 2012-9-8 13:01:30

带过滤表的entsel

本帖最后由 smartstar 于 2012-9-8 15:40 编辑

;|
功能:      类似于(entsel)函数,带提示,且带一个过滤表,只选择表中类型[若过滤表为nil,则同(entsel)函数]。
                鼠标左键点到空白处或选择错误对象类型将继续选择,回车(或鼠标右键)结束选择。

例子:      (ark-entsel "\n点选对象:" nil)
例子:      (ark-entsel "\n选择直线或圆:" '((0 . "*LINE,CIRCLE")))

返回:      同(entsel)一样,(对象名 选择点)
|;
(defun ark-entsel (msg filter)
(while
    (progn
      (setvar 'ERRNO 0)
      (setq sel (entsel msg))
      (cond
      ((= 7 (getvar 'ERRNO))
         (princ "\n没有选中,请重新尝试!")
      )
      ((not sel)
         nil
      )
      ((listp sel)
         (sssetfirst nil (ssadd (car sel)))
         (sssetfirst nil)
         (if (not (null filter))
         (if (not(ssget "p" filter))
             (princ "\n对象类型错误,请重新选择!")
         )
         )
      )
      )
    )
)
sel
)

自贡黄明儒 发表于 2012-9-8 16:19:07

C版也发表过,我一直在用

革天明 发表于 2012-9-8 16:44:10

本帖最后由 革天明 于 2012-9-8 16:46 编辑

看起来和楼主共享的那个很相似,我也是淘来的,我不知道原作者,说明里面有声明
;;=============================================================================================
;;功能:带提示、关键字、过滤表、选择错误时的提示并且会亮显所选对像的entsel
;;用法:( clh-entsel提示信息关键字过滤表选择错误时提示)
;;举例:(clh-entsel"\n请选择一个圆:""A B C"   '((0 . "circle"))"\n所选对像不符合要求!请重新选择:")
;;说明:过滤表与ssget的过滤表相同;函数由CLH521,2009.6.7参考了一些网上资料整理编写
(defun clh-entsel (msg key fil ermsg / el ss)
   (while
   (and
       (setvar "errno" 0)
       (not
         (and (setq
                el (apply '(lambda (msg key) (initget key) (entsel msg))
                        (list msg key)
                   )
            )
            (if (= (type el) 'str)
                el
                (if (setq ss (ssget (cadr el) fil))
                  ss
                  (progn (alert ermsg) (setq ss nil))
                )                        ;if
            )                              ;if
         )                              ;and
       )                                        ;not
       (/= (getvar "errno") 52)
   )                                        ;and
   )                                        ;while
   (if (= (type el) 'list)
   (redraw (car el) 3)
   )                                        ;亮显选中的对像
   el
)
;;clh-entsel函数完毕========================================================

tm20038175 发表于 2012-9-8 19:01:10

革天明 发表于 2012-9-8 16:44
看起来和楼主共享的那个很相似,我也是淘来的,我不知道原作者,说明里面有声明
;;====================== ...

要做到能支持块内图元就算完美了!…
页: [1]
查看完整版本: 带过滤表的entsel