nicgosselin_so_hot
2008-07-07, 08:07 PM
I have to select object in my drawing by using the handle of this object.I found a lisp file do it very well by using blank just have to select all drawing and after unblank the handle of the object and just this object can be visible after modification just unblankall it's fantastic but the problem is the command can't hide viewports and it's specially for viewports i have to do this....somebody can help me please!
Or somebody know how I can do a selection by using the handle of object...
can respond here or by mail at nickgosselin@videotron.ca
Thanks in advance!
here the lisp of the command i found:
(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)
Or somebody know how I can do a selection by using the handle of object...
can respond here or by mail at nickgosselin@videotron.ca
Thanks in advance!
here the lisp of the command i found:
(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)