All pastes #576628 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-06-19 15:42 UTC
rendered paste body
;--------------------------------------------------------;
;            Keynote Renumber V 1.10 [6-12-07]           ;
;        Written by Derek Jarvis (djarvis@cox.net)       ;
;--------------------------------------------------------;
;  1.11 - Added ability to select block to get name      ;
;							 ;
;  1.10 - Added support for letter renumbering (not      ;
;         intuitive "z+1" will not wrap back to "a" and  ;
;         only one character in length is supported)     ;
;--------------------------------------------------------;
(defun c:knr ( / blk2sel incrval rngbgn rngend rnsel blkinc blkchgd blkcnt curatti curattv newval)
(setq echoset (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq blk2sel(getstring T "Name of block to renumber? <select>"))
(if (= blk2sel "") (setq blk2sel (cdr (assoc 2 (entget (car (entsel)))))))
(setq incrval(getstring "Difference \(+\):"))
(setq rngbgn(getstring "Start at:"))
(setq rngend(getstring "End at:"))
(setq rnsel (ssget "x" (list (cons 0 "INSERT") (cons 2 blk2sel))))
(setq blkinc 0)
(setq blkchgd 0)
(setq blkcnt (1-(sslength rnsel)))
(while (<= blkinc blkcnt)
	(setq newval nil)
	(setq curatti (entget(entnext(ssname rnsel blkinc))))
	(setq curattv (cdr(assoc 1 curatti)))
	(if (wcmatch curattv "#*")(if (= (isRange (atoi rngbgn) (atoi rngend) (atoi curattv)) "T") (setq newval (rtos(+ (atoi incrval) (atoi curattv)) 2 0))))
	(if (wcmatch curattv "@*")(if (= (isRange (ascii rngbgn) (ascii rngend) (ascii curattv)) "T") (setq newval (chr(+ (atoi incrval) (ascii curattv))))))
	(if newval 
		(progn
		(entmod (subst (cons 1 newval) (assoc 1 curatti) curatti))
		(setq blkchgd(1+ blkchgd))
		)
	)
	(setq blkinc (1+ blkinc))
)
(command "_.regen")
(princ (strcat (rtos blkchgd 2 0) " blocks were changed\n"))
(setvar "cmdecho" echoset)
)
(defun isRange (start end value)(if (>= value start) (if (<= value end) (setq x "T") (setq x "F"))))