flytoday 发表于 2012-3-31 23:13:48

请问为什么隐显对象对象有时行有时不行

本帖最后由 flytoday 于 2012-3-31 23:17 编辑

(defun c:DOFF (/ ss)
(vl-load-com)
(prompt "\n 选择对象隐藏: ")
(if (setq ss (ssget))
((lambda (i / e)
(while (setq e (ssname ss (setq i (1+ i))))
(vla-put-visible
(vlax-ename->vla-object e)
:vlax-false)))
-1))
(princ))
;--------------------------------------------------
(defun c:DON (/ ss)
(vl-load-com)
(prompt "\n 所有的对象已打开... ")
(if (setq ss (ssget "_x"))
((lambda (i / e)
(while (setq e (ssname ss (setq i (1+ i))))
(vla-put-visible
(vlax-ename->vla-object e)
:vlax-true)))
-1))
(princ))
;---------------------对象的隐藏和取消隐藏-------------------



有时候隐藏是隐藏了就是显示不出来.....
有时有些对些对象不能隐藏了(天正的墙体之类的不能隐藏)
提示
; 错误: Automation 错误。未提供说明。
哪位大侠帮修改下..让程序适用天正及CAD所有对象都能隐藏显示///谢谢

Gu_xl 发表于 2012-3-31 23:13:49

本帖最后由 Gu_xl 于 2012-4-1 12:00 编辑

显示隐藏工具
**** Hidden Message *****

yjr111 发表于 2012-4-1 00:39:36

;;;---------------------------------------------------------------------------;
;;;
;;;   BLANK.LSP   Version 1.0
;;;
;;;   Copyright (C) 1995 by Autodesk, Inc.
;;;
;;;   Permission to use, copy, modify, and distribute this software and its
;;;   documentation for any purpose and without fee is hereby granted.
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;
;;;---------------------------------------------------------------------------;
;;;   BLANK, UNBLANK, and UNBLANKALL
;;;
;;;   This module provides functions to manipulate the visibility field of
;;;   AutoCAD objects.BLANK will make a selection set of objects invisible.
;;;   UNBLANK will make a specified object (given its handle) visible.
;;;   UNBLANKALL will make all blanked entities visible.
;;;
;;;---------------------------------------------------------------------------;


;;;---------------------------------------------------------------------------;
;;; Internal error handling.
;;;---------------------------------------------------------------------------;
(defun blank_error(s)
;; The strings in the following statements can be translated.
(if (/= s ;|MSG1|;"Function cancelled")
    (princ (strcat ;|MSG2|;"\nBLANK Error: " s))
)
(setq *error* olderr)
(princ)
)

(defun unblank_error(s)
;; The strings in the following statements can be translated.
(if (/= s ;|MSG3|;"Function cancelled")
    (princ (strcat ;|MSG3|;"\nUNBLANK Error: " s))
)
(setq *error* olderr)
(princ)
)

(defun blank60 (e / e2)
(if (not (null (assoc '60 e)))
    (setq e2 (subst '(60 . 1) '(60 . 0) e))
    (setq e2 (append e '((60 . 1))))
)
)   

(defun show60 (e / e2)
(if (not (null (assoc '60 e)))
   (setq e2 (subst '(60 . 0) '(60 . 1) e))
   (setq e2 (append e '((60 . 0))))
)
)

(defun setvis ( vis ename / e)
(setq e (entget ename))
(if (eq vis 0)
   (entmod (show60 e))
   (entmod (blank60 e))
)
(entupd ename)
;; Blank vertices of polyline, if necessary
(if (eq (cdr (nth 1 e)) "POLYLINE")
    (progn
      (setq ename (entnext ename))
      (setq e (entget ename))
      (while (eq (cdr (nth 1 e)) "VERTEX")
      (if (eq vis 0)
         (entmod (show60 e))
         (entmod (blank60 e))
      )
      (entupd ename)
      (setq ename (entnext ename))
      (setq e (entget ename))
      ) ; while
    ) ; progn
) ; if polyline
(if (and (eq (cdr (nth 1 e)) "INSERT")
         (assoc '66 e))
    (progn
      (setq ename (entnext ename))
      (setq e (entget ename))
      (while (eq (cdr (nth 1 e)) "ATTRIB")
      (if (eq vis 0)
         (entmod (show60 e))
         (entmod (blank60 e))
      )
      (entupd ename)
      (setq ename (entnext ename))
      (setq e (entget ename))
      ) ; while
    ) ; progn
)
)

(defun c:blank ( ) ;;; / olderr echo ss i ename )
(setq olderr *error*                ; Redefine error handler.
      echo (getvar ;|MSG0|;"cmdecho")
      *error* blank_error)
(setvar ;|MSG0|;"cmdecho" 0)                ; Turn off cmdecho sysvar
(command ;|MSG0|;"_.undo" ;|MSG0|;"_group")

(setq ss (ssget))
(setq i 0)
(while (< i (sslength ss)) (progn
   (setq ename (ssname ss i))
   (setvis 1 ename)
   (setq i (1+ i))
))

(setq *error* old_error)            ; restore error function
(command ;|MSG0|;"_.undo" ;|MSG0|;"_end")
(setvar ;|MSG0|;"cmdecho" echo)             ; restore cmdecho sysvar
(princ)                           ; Quiet exit.
)

(defun c:unblankall ( ) ;;; / olderr echo ss i ename )
(setq olderr *error*                ; Redefine error handler.
      echo (getvar ;|MSG0|;"cmdecho")
      *error* unblank_error)
(setvar ;|MSG0|;"cmdecho" 0)                ; Turn off cmdecho sysvar
(command ;|MSG0|;"_.undo" ;|MSG0|;"_group")

;; Select all blanked entities
(setq ss (ssget ;|MSG0|;"_x" '((60 . 1))))
(if (not (null ss))
    (progn
      (setq i 0)
      (princ (sslength ss))
      (princ " blanked entities found.\n");
      ;; Unblank each entity in the set
      (while (< i (sslength ss)) (progn
         (setq ename (ssname ss i))
         (setvis 0 ename)
         (setq i (1+ i))
      ))
    )   
    (princ "\n0 blanked entities found.\n");
)

(setq *error* old_error)            ; restore error function
(command ;|MSG0|;"_.undo" ;|MSG0|;"_end")
(setvar ;|MSG0|;"cmdecho" echo)             ; restore cmdecho sysvar
(princ)                           ; Quiet exit.
)

(defun c:unblank ( ) ;;; / olderr echo ss i ename hand )
(setq olderr *error*                ; Redefine error handler.
      echo (getvar ;|MSG0|;"cmdecho")
      *error* unblank_error)
(setvar ;|MSG0|;"cmdecho" 0)                ; Turn off cmdecho sysvar
(command ;|MSG0|;"_.undo" ;|MSG0|;"_group")

(setq hand (getstring ;|MSG5|;"\nEnter handle of entity to be unblanked: "))
;; Unblank the entity if handle is not an empty string
(if (> (strlen hand) 0)
    (progn
      (setq ename (handent hand))
      (if (/= nil ename)
      (setvis 0 ename)
      (princ ;|MSG6|;"Invalid handle.")
      )
    )
)

(setq *error* old_error)            ; restore error function
(command ;|MSG0|;"_.undo" ;|MSG0|;"_end")
(setvar ;|MSG0|;"cmdecho" echo)             ; restore cmdecho sysvar
(princ)                           ; Quiet exit.
)

BLANK隐藏实体 UNBLANKALL显示所有实体

flytoday 发表于 2012-4-1 09:21:13

严哥这个在天正中多选择对象直接CAD崩溃,。卡住退出了哦。。不过也是很感谢

flytoday 发表于 2012-4-1 09:51:02

当然G版肯出手一定行呵呵。。。

flytoday 发表于 2012-4-1 09:54:01

很关键滴是有些对象隐藏了显示不出来

ㄘ丶转裑ㄧ灬 发表于 2012-4-1 10:02:24

flytoday 发表于 2012-4-1 09:21 static/image/common/back.gif
严哥这个在天正中多选择对象直接CAD崩溃,。卡住退出了哦。。不过也是很感谢

额。。。天正的工具里不是有局部隐藏吗、、、
我也开着天正,用严哥这程序一切正常、、、、、8.5+2012

ㄘ丶转裑ㄧ灬 发表于 2012-4-1 10:06:38

悲剧,确实对天正墙体之类的不能隐藏,一用就崩溃、、、、

Andyhon 发表于 2012-4-1 10:07:21

Ref:
http://www.mjtd.com/Codes/ArticleShow.asp?ArticleID=988

未审天正合用否

ㄘ丶转裑ㄧ灬 发表于 2012-4-1 10:19:17

Andyhon 发表于 2012-4-1 10:07 static/image/common/back.gif
Ref:
http://www.mjtd.com/Codes/ArticleShow.asp?ArticleID=988



、、、、除了隐藏和显示所有,其他的都不会用、、、
暂时没有崩溃现象、、、
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: 请问为什么隐显对象对象有时行有时不行