Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
this lisp works like "tcount.lsp" but just in block-attributes, this lisp works great but I need options like Suffix and Prefix.
Can anyone help me?
(defun c:tcount_att (/ ss ob start_num inc_num sum ename new_value OLDER *error*) (vl-load-com) (setq OLDER *error* *error* myerror) (if (setq ss (ssget '((0 . "INSERT")))) (progn (initget 1 "X Y Select") (setq ob (getkword "\nSort selected objects by [X/Y/Select-order] <Select-order>: ")) (cond ((= ob "X") (setq ss (sort_x ss)) ) ((= ob "Y") (setq ss (sort_y ss)) ) ((= ob "Select") (setq ss (sort ss)) ) );cond (setq start_num (getint "\nSpecify starting number <1>: ")) (if (= start_num nil) (setq start_num 1) (setq start_num start_num) ) (setq inc_num (getint "\nSpecify increment number <1>: ")) (if (= inc_num nil) (setq inc_num 1) (setq inc_num inc_num) );if (setq sum 0) (setq sum (apply '+ (list sum start_num))) (setq ename (entnext (car ss))) (if (/= (cdr (assoc 0 (entget ename))) "SEQEND") (progn (setq new_value (rtos sum 2 0)) (entmod (subst (cons 1 new_value) (assoc 1 (entget ename)) (entget ename))) (entupd (car ss)) ) ) (mapcar '(lambda (obj) (setq sum (apply '+ (list sum inc_num))) (setq ename (entnext obj)) (if (/= (cdr (assoc 0 (entget ename))) "SEQEND") (progn (setq new_value (rtos sum 2 0)) (entmod (subst (cons 1 new_value) (assoc 1 (entget ename)) (entget ename))) (entupd obj) ) ) ) (cdr ss) ) );progn );if (setq *error* OLDER) (princ) );defun ;;;;;;;; (defun sort_x (ss / n ss1 ) (setq ss1 nil) (setq n 0) (repeat (sslength ss) (setq ss1 (append ss1 (list (ssname ss n)))) (setq n (1+ n)) );repeat (setq ss1 (vl-sort ss1 '(lambda (e1 e2) (< (car (cdr (assoc 10 (entget e1)))) (car (cdr (assoc 10 (entget e2)))) ) ) ) );setq ) ;;;;;;;; (defun sort_y (ss / n ss1 ) (setq ss1 nil) (setq n 0) (repeat (sslength ss) (setq ss1 (append ss1 (list (ssname ss n)))) (setq n (1+ n)) ) (setq ss1 (vl-sort ss1 '(lambda (e1 e2) (< (cadr (cdr (assoc 10 (entget e1)))) (cadr (cdr (assoc 10 (entget e2)))) ) ) ) );setq ) ;;;;;;;; (defun sort (sset / n ss1 ) (setq ss1 nil) (setq n 0) (repeat (sslength ss) (setq ss1 (append ss1 (list (ssname ss n)))) (setq n (1+ n)) ) ss1 ) ;;;;;;;;;;;;;;;;;;;;;; (defun myerror (s) (cond ((= s "quit / exit abort") (princ)) ((/= s "Function cancelled") (princ (strcat "\nError: " s))) ) (setq *error* OLDER) (princ) )
Solved! Go to Solution.