也许是这样的
- (defun c:test (/ DATA I II N NEW OLD SS)
- (if (setq ss (ssget "_X" '((0 . "INSERT"))));; select insert
- (progn
- (setq n (sslength ss));; sets n with the selection set lenght
- (while (not (minusp (setq n (1- n))));; while n not negative, set n -1
- (if (and (setq data (entget (ssname ss n)));; object definition data
- (setq old (cdr (assoc 2 data)));; block name
- (not (assoc 1 (tblsearch "BLOCK" old)));; not Xref
- (setq i (vl-string-search "Level" old));; Level position
- (setq i (1- i));; - before Level
- (if (setq ii (vl-string-search "M_" old));; M_ position
- (setq ii (+ ii 3));; after M_ position
- (setq ii 1);;if not M_ position
- );; if
- (setq new (substr old ii i));; new name removing the level
- (not (tblsearch "BLOCK" new));; search if name exists, and if not
- );; and
- (command "._rename" "_block" old new);; rename the block
- );; if
- );; while
- );; progn
- );; if
- (princ)
- );; test
亨里克 |