Jump to content

Help to improve a sequential numbering lisp


pioptl

Recommended Posts

I have a great lisp that sequentially numbers/letters existing text or blocks with attributes. I'm not well versed in lisp. I was wondering if someone could possibly modify this lisp to also work on multileaders w/text and more importantly multileaders with a block that contains an attribute. Or maybe there is already a lisp out there that already exists?

 

Thanks, in advance,

(I'm not sure where this lisp came from or who authored it).

Here is the lisp code:

 

;  SEQ.LSP          Sequential text 

;;Automatic Sequential Numbering and Lettering
(defun *ERROR*  (MSG)
 (princ MSG)
 (princ "\nFunction cancelled")
 (princ)
 )

(defun SQN  ()
 (princ "\n")
 (princ SEQ)
 (setq ENT (entget (car (nentsel "\n - Select Text to Number"))))
 (while ENT
   (if (or (= (cdr (assoc 0 ENT)) "TEXT")
           (= (cdr (assoc 0 ENT)) "ATTRIB"))
     (progn
       (entmod
         (subst (cons 1 SEQ) (assoc 1 ENT) ENT)
         )
       (entupd (cdr (car ENT)))
       (setq SEQ (itoa (1+ (read SEQ))))
       )
     (princ "\nEntity Must be TEXT")
     )
   (princ "\n")
   (princ SEQ)
   (setq ENT (entget (car (nentsel " - Select Text: "))))
   (setq *SEQ (itoa (1+ (read SEQ))))
   )
 )

(defun SQL  ()
 (princ "\n")
 (princ SEQ)
 (setq ENT (entget (car (nentsel "\nSelect Text to Letter"))))
 (while ENT
   (if (or (= (cdr (assoc 0 ENT)) "TEXT")
           (= (cdr (assoc 0 ENT)) "ATTRIB"))
     (progn
       (entmod
         (subst (cons 1 SEQ) (assoc 1 ENT) ENT)
         )
       (entupd (cdr (car ENT)))
       (setq SEQ (chr (1+ (ascii SEQ))))
       )
     (princ "\nEntity Must be TEXT")
     )
   (princ "\n")
   (princ SEQ)
   (setq ENT (entget (car (nentsel " - Select Text: "))))
   (setq *SEQ (chr (1+ (ascii SEQ))))
   )
 )

(defun C:SEQ  (/ SEQ ENT)
 (if (not *SEQ)
   (setq *SEQ "1")
   )
 (princ (strcat "\nStarting Letter or Number <" *SEQ "> :"))
 (setq SEQ (getstring))
 (if (not (read SEQ))
   (setq SEQ *SEQ)
   (setq *SEQ SEQ)
   )
 (setq NUM (numberp (read SEQ)))
 (setvar "cmdecho" 0)
 (graphscr)
 (if (not NUM)
   (SQL)
   (SQN)
   )
 (setvar "cmdecho" 1)
 (princ)
 )

Edited by pioptl
Link to comment
Share on other sites

This may help it works with numbers or alpha 1 A a, version two will check for last number/apha

 

; bubble pt num
; BY ALAN H AUG 2014

(alert "Type Bub to repeat")

(defun C:bub ( / ptnum ptnumb pt pt2 oldsnap chrnum)
(setq oldsnap (getvar "osmode"))

(setvar "textstyle" "standard")
(setq ptnum (getstring "\nEnter Pt Number or alpha"))
(setq chrnum (ascii (substr ptnum 1 1))) ; 1st character is number
(if (< chrnum 58)
(setq ptnumb (atof ptnum)) ;convert back to a number 
)


(while (setq pt (getpoint "\Pick end of line Enter to exit"))
(setq pt2 (polar pt (/ pi 2.0) 3.0))
(setvar "osmode" 0)
      
(Command "circle" pt 3.0)
(command "move" "L" "" pt pt2)
(if (< chrnum 58)
(progn
(command "-Text" "J" "MC" pt "3.0" "" (rtos ptnumb 2 0))
(setq ptnumb (+ ptnumb 1))
)
(progn
(command "-Text" "J" "MC" pt "3.0" "" (chr chrnum)) 
(setq chrnum (+ chrnum 1))
)
)
(command "move" "L" "" pt pt2)
(setvar "osmode" 1)
)

(setvar "osmode" oldsnap)
(princ)
) ; end defun
(C:BUB)
(princ)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...