老师,我想请教-下怎样用visual lisp编程隐藏实体和显示实体??
www.dimcax.com
老师,我想请教-下怎样用visual lisp编程隐藏实体和显示实体??
d
用lisp编程隐藏实体和显示实体如內,但用visual lisp编程的就沒有了!!!;;;---------------------------------------------------------------------------;
;;;
;;; 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.
)
(princ)
要努力学习,不进则退
网络u盘:
谢谢老师,不愧为高手!
d
你的程序我看了一下,请问(setvar ;|msg0|;"cmdecho" 0)怎样理解?
d
程序中unblank函数不知怎样用??
d
我简化了一下这个程序(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 gettype(e / type)
(setq type 0)
(if (assoc 60 e)
(setq type (cdr (assoc 60 e)))
)
type
)
(defun c:swd(/ ss n en el)
(setq ss (ssget))
(if ss
(setq n (sslength ss))
(setq n 0)
)
(repeat n
(setq en (ssname ss (setq n (1- n)))
el (entget en)
)
(if (= (gettype el) 0)
(setq el (blank60 el))
(setq el (show60 el))
)
(entmod el)
)
(princ)
)
;其实lisp程序可用于alisp中