试试这个,也更新了我以前的代码。。。
- (defun c:showblkbydate ( / remchar date bl ss i )
- (vl-load-com)
- (defun remchar ( char str / strn ch )
- (setq strn "")
- (while (/= str "")
- (setq ch (substr str 1 1))
- (if (= ch char)
- (setq ch "")
- )
- (setq str (substr str 2))
- (setq strn (strcat strn ch))
- )
- strn
- )
- (initget 1)
- (setq date (getstring "\nSpecify range check date ex. "2016-08-01" : "))
- (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
- (if
- (and
- (not (wcmatch (strcase (vla-get-name b)) "*MODEL*,*PAPER*"))
- (= (vla-get-isxref b) :vlax-false)
- (/= (vla-get-comments b) "")
- )
- (setq bl (cons (cons (vla-get-comments b) b) bl))
- )
- )
- (setq bl
- (vl-sort bl '(lambda ( a b )
- (if (= (atoi (remchar "-" (substr (car a) 1 10))) (atoi (remchar "-" (substr (car b) 1 10))))
- (< (atoi (remchar "-" (substr (car a) 12))) (atoi (remchar "-" (substr (car b) 12))))
- (< (atoi (remchar "-" (substr (car a) 1 10))) (atoi (remchar "-" (substr (car b) 1 10))))
- ))
- )
- )
- (setq bl
- (vl-remove-if-not '(lambda ( x )
- (< (atoi (remchar "-" (substr (car x) 1 10))) (atoi (remchar "-" date)) (atoi (remchar "-" (substr (car x) 12))))
- )
- bl
- )
- )
- (if bl
- (foreach b bl
- (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 (vla-get-name (cdr b))))))
- (if ss
- (repeat (setq i (sslength ss))
- (prompt "\nENTER TO CONTINUE...")
- (command "_.ISOLATEOBJECTS" (ssname ss (setq i (1- i))) "")
- (while (progn (setq gr (grread nil)) (if (or (equal gr '(2 13)) (equal gr '(2 32))) (setq gr nil) t)))
- (command "_.UNISOLATEOBJECTS")
- )
- )
- )
- )
- (princ)
- )
M、 R。 |