明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: 龙龙仔

[LISP]超級隱藏/顯示工具

  [复制链接]
发表于 2009-1-17 11:24 | 显示全部楼层
晕倒,老子看不到代码
发表于 2009-1-29 12:46 | 显示全部楼层

;|
超級隱藏/顯示工具
;;这是无痕的思路(不会用就找他)
;;超级隐藏/显示工具
;;By LUCAS(龙龙仔)

(prompt "\n超级隐藏/显示工具-------------龙龙仔.2004.1")
(alert
  (strcat
    "\n\n--------------------------------------------------------------------------"
    "\n\n----------------超级隐藏/显示工具(测试版V0)-------------------"
    "\n\n---------------------------龙龙仔.2004.1-----------------------------"
    "\n\n--------------------------------------------------------------------------"
    "\n\nE-显示所有/D-隐藏所有/V-显示记录/C-隐藏记录"
    "\n\nS-显示上个/F-显示下个/空格-显示锁定/R-显示解锁"
    "\n\nB-显示记录/X-退出/Q-删除标记/Z-清空记录/A-增加隐藏:"
    "\n\n--------------------------------------------------------------------------"
    "\n\n--------------------(XSHOW_LAI <词典名称>)--------------------"
    "\n\n----------------------------C:XSHOWALL----------------------------"
    "\n\n----------------------------C:XHIDEALL-----------------------------"
   )
)
|;
;;这是无痕的思路(不会用就找他)
;;超级隐藏/显示工具
;;By LUCAS(龙龙仔)
;;写好就没有用过.......
(vl-load-com)
(defun C:XSHOWALL (/ SSOBJ ENT)
  (if
    (and (ssget "X" (list (cons 60 1) (cons 410 (getvar "CTAB"))))
  (setq SSOBJ (ssget "X" (list (cons 410 (getvar "CTAB")))))
    )
     (progn
       (setq
  SSOBJ (vla-get-activeselectionset
   (vla-get-activedocument (vlax-get-acad-object))
        )
       )
       (vlax-for ENT SSOBJ
  (vla-put-visible ENT :vlax-true)
       )
       (prompt "\n显示所有物件!")
     )
     (prompt "\n无隐藏物件!")
  )
  (princ)
)

(defun C:XHIDEALL (/ SSOBJ ENT)
  (if (setq SSOBJ (ssget "X" (list (cons 410 (getvar "CTAB")))))
    (progn
      (setq
 SSOBJ (vla-get-activeselectionset
  (vla-get-activedocument (vlax-get-acad-object))
       )
      )
      (vlax-for ENT SSOBJ
 (vla-put-visible ENT :vlax-false)
      )
      (prompt "\n隐藏所有物件!")
    )
  )
  (princ)
)

;;(CHECK "LUNG")
(defun CHECK (DICT / DICT_KEY ENT LL N)
  (setq DICT_KEY (vlax-ldata-list DICT)
 N  0
  )
  (repeat (length DICT_KEY)
    (setq LL (cons (car (nth N DICT_KEY)) LL))
    (setq N (1+ N))
  )
  LL
)

;;(DICT_OFF "LUNG" "1")
(defun DICT_OFF (DICT KEY / SS ENT)
  (setq SS (cdr (assoc KEY (vlax-ldata-list DICT))))
  (foreach ENT SS
    (if (and (setq ENT (handent ENT)) (entget ENT))
      (vla-put-visible (vlax-ename->vla-object ENT) :vlax-false)
    )
  )
  (princ)
)

;;(DICT_ON "LUNG" "1")
(defun DICT_ON (DICT KEY / SS ENT)
  (setq SS (cdr (assoc KEY (vlax-ldata-list DICT))))
  (foreach ENT SS
    (if (and (setq ENT (handent ENT)) (entget ENT))
      (vla-put-visible (vlax-ename->vla-object ENT) :vlax-true)
    )
  )
  (princ)
)

;;(MAKE_DICT "LUNG" "1" (SSGET))
(defun MAKE_DICT (DICT KEY SS / ENAME_LIST N)
  (setq N 0)
  (repeat (sslength SS)
    (setq ENAME_LIST
    (cons (cdr (assoc 5 (entget (ssname SS N))))
   ENAME_LIST
    )
    )
    (setq N (1+ N))
  )
  (vlax-ldata-put DICT KEY ENAME_LIST)
)

;;主程序
;;(XSHOW_LAI "LUNG")
(defun XSHOW_LAI (DICT / KEY N LEN LIS LIS1 LOOP MSG MODE S1 TMPKEY)

  (if (not (setq N (vlax-ldata-get (strcat DICT "_N") "N")))
    (progn
      (setq N 1)
      (vlax-ldata-put (strcat DICT "_N") "N" 1)
    )
  )
  (if (not (setq LIS (vlax-ldata-get (strcat DICT "_LIS") "LIS")))
    (progn
      (setq LIS '())
      (vlax-ldata-put (strcat DICT "_LIS") "LIS" LIS)
    )
  )

  (setq LOOP t)
  (setq MSG
  "\nE-显示所有/D-隐藏所有/V-显示记录/C-隐藏记录/S-显示上个/F-显示下个/空格-显
示锁定/R-显示解锁/B-显示记录/X-退出/Q-删除标记/Z-清空记录/A-增加隐藏:"
  )
  (while LOOP
    (setq MODE (grread t 4 2))
    (prompt MSG)
    (cond

      ((member MODE '((2 13) (2 88) (2 120) (11 0)))
       (setq LOOP NIL)
      )

      ((member MODE '((2 65) (2 97)))    ;A
       (if (CHECK DICT)
  (setq KEY (rtos (1+ (last (setq KEY_LIST
       (vl-sort (mapcar 'atof (CHECK DICT)) '<)
       )
        )
    )
     )
  )
  (setq KEY "1")
       )
       (setq LEN (length (vlax-ldata-list DICT)))
       ;;(vlax-ldata-put "LUNG" "KEY_LIST" KEY_LIST)
       ;;(setq KEY (rtos (1+ (apply 'max (mapcar 'atof (CHECK "LUNG"))))))
       (prompt "\n增选隐藏物件:")
       (setq S1 (ssget))
       (if S1
  (MAKE_DICT DICT KEY S1)
       )
      )

      ((member MODE '((2 69) (2 101)))    ;E
       (C:XSHOWALL)
      )

      ((member MODE '((2 100) (2 68)))    ;D
       (C:XHIDEALL)
      )

      ((member MODE '((2 67) (2 99)))    ;C
       (setq CHECK_LIST (CHECK DICT))
       (mapcar '(lambda (X)
    (DICT_OFF DICT X)
  )
        CHECK_LIST
       )
       (prompt "\n隐藏所有标记物件!")
      )

      ((member MODE '((2 86) (2 118)))    ;V
       (setq CHECK_LIST (CHECK DICT))
       (mapcar '(lambda (X)
    (DICT_ON DICT X)
  )
        CHECK_LIST
       )
       (prompt "\n显示所有标记物件!")
      )

      ((member MODE '((2 83) (2 115)))    ;S
       (if (not (setq N (vlax-ldata-get (strcat DICT "_N") "N")))
  (progn
    (setq N 1)
    (vlax-ldata-put (strcat DICT "_N") "N" 1)
  )
       )
       (if (setq LIS1 (CHECK DICT))
  (progn
    (setq LEN (length LIS1))
    (if (= N (1- LEN))
      (setq N 0)
      (setq N (1+ N))
    )
    (DICT_ON DICT (nth N LIS1))
    (if (= N 0)
      (setq TMPKEY (nth (1- LEN) LIS1))
      (setq TMPKEY (nth (1- N) LIS1))
    )
    (if (not (member TMPKEY LIS))
      (DICT_OFF DICT TMPKEY)
    )
    (vlax-ldata-put (strcat DICT "_N") "N" N)
    (prompt (strcat "\n显示第"
      (nth N LIS1)
      "笔物件,锁定串列="
      (vl-prin1-to-string LIS)
     )
    )
  )
       )
      )

      ((member MODE '((2 102) (2 70)))    ;F
       (if (not (setq N (vlax-ldata-get (strcat DICT "_N") "N")))
  (progn
    (setq N 1)
    (vlax-ldata-put (strcat DICT "_N") "N" 1)
  )
       )
       (if (setq LIS1 (CHECK DICT))
  (progn
    (setq LEN (length LIS1))
    (if (= N 0)
      (setq N (1- LEN))
      (setq N (1- N))
    )
    (DICT_ON DICT (nth N LIS1))
    (if (= N (1- LEN))
      (setq TMPKEY (nth 0 LIS1))
      (setq TMPKEY (nth (1+ N) LIS1))
    )
    (if (not (member TMPKEY LIS))
      (DICT_OFF DICT TMPKEY)
    )
    (vlax-ldata-put (strcat DICT "_N") "N" N)
    (prompt (strcat "\n显示第"
      (nth N LIS1)
      "笔物件,锁定串列="
      (vl-prin1-to-string LIS)
     )
    )
  )
       )
      )

      ((member MODE '((2 32)))     ;""
       (if (setq LIS1 (CHECK DICT))
  (progn
    (if
      (not (setq LIS (vlax-ldata-get (strcat DICT "_LIS") "LIS"))
      )
       (progn
  (setq LIS '())
  (vlax-ldata-put (strcat DICT "_LIS") "LIS" LIS)
       )
    )
    (if (not (member (nth N LIS1) LIS))
      (setq LIS (append LIS (list (nth N LIS1))))
    )
    (vlax-ldata-put (strcat DICT "_LIS") "LIS" LIS)
    (prompt (strcat "\n显示锁定串列"
      (vl-prin1-to-string LIS)
      ",目前显示第"
      (nth N LIS1)
      "笔物件"
     )
    )
  )
       )
      )

      ((member MODE '((2 114) (2 82)))    ;R
       (if (setq LIS1 (CHECK DICT))
  (progn
    (if
      (not (setq LIS (vlax-ldata-get (strcat DICT "_LIS") "LIS"))
      )
       (progn
  (setq LIS '())
  (vlax-ldata-put (strcat DICT "_LIS") "LIS" LIS)
       )
    )
    (if (member (nth N LIS1) LIS)
      (setq LIS (vl-remove (nth N LIS1) LIS))
    )
    (vlax-ldata-put (strcat DICT "_LIS") "LIS" LIS)
    (prompt (strcat "\n显示锁定串列"
      (vl-prin1-to-string LIS)
      ",目前显示第"
      (nth N LIS1)
      "笔物件"
     )
    )
  )
       )
      )

      ((member MODE '((2 122) (2 90)))    ;Z
       ;|
       (setq
  KEY_LIST1 (mapcar 'rtos
      (vl-sort (mapcar 'atof (CHECK "LUNG")) '<)
     )
       )|;
       ;|
       (setq CHECK_LIST (CHECK "LUNG"))
       (mapcar '(lambda (X)
    (vlax-ldata-delete "LUNG" X)
  )
        CHECK_LIST
       )|;
       (initget "Y ")
       (if (getkword "\n真的要清除所有标记物件!<N>:")
  (progn
    (dictremove (namedobjdict) DICT)
    (dictremove (namedobjdict) (strcat DICT "_N"))
    (dictremove (namedobjdict) (strcat DICT "_LIS"))
    (prompt "\n已清除所有标记物件!")
  )
  (prompt "\n保留标记物件!")
       )
      )

      ((member MODE '((2 113) (2 81)))    ;Q
       (if (setq LIS1 (CHECK DICT))
  (progn
    (DICT_ON DICT (nth N LIS1))
    (vlax-ldata-delete DICT (nth N LIS1))
    (prompt (strcat "\n已删除"
      (nth N LIS1)
      "标记,目前标记"
      (vl-prin1-to-string (CHECK DICT))
     )
    )
    (setq N 1)
  )
       )
      )
      ((member MODE '((2 66) (2 98)))
       (prompt
  (strcat "\n目前标记" (vl-prin1-to-string (CHECK DICT)))
       )
      )
    )
  )
  (princ)
)

发表于 2009-2-25 12:37 | 显示全部楼层
好东西,可惜要威望,看不了,
发表于 2009-9-25 00:06 | 显示全部楼层
龙龙仔,强!
发表于 2009-11-23 00:10 | 显示全部楼层
学习学习
发表于 2010-6-23 11:10 | 显示全部楼层
下來 試試看~~~~
发表于 2010-8-23 07:46 | 显示全部楼层
人谦虚,东西实在
发表于 2010-9-23 23:44 | 显示全部楼层
看不到
发表于 2010-9-26 13:50 | 显示全部楼层
看看什么东西
发表于 2010-9-30 07:10 | 显示全部楼层
支持
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-25 08:52 , Processed in 0.545992 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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