Auto Numbering Cable Numbers That Can Edit Text or Attributes

Auto Numbering Cable Numbers That Can Edit Text or Attributes

tracybrown
Participant Participant
222 Views
1 Reply
Message 1 of 2

Auto Numbering Cable Numbers That Can Edit Text or Attributes

tracybrown
Participant
Participant

I am currently utilizing a Lisp script that effectively updates cable numbers formatted as text. However, with recent changes in our numbering methodology, where cable numbers are now assigned using attributes, I find the need to enhance the script to accommodate this update.

The existing script appends "OO" to cable numbers less than 10 and a single "O" to numbers less than 100. For the enhanced version, it would be optimal to maintain this functionality but ensure that numbers equal to or greater than 100 are left unmodified without any added zeros.

Looking for an Lisp routine to support both text and attributes while adhering to the numbering modifications specified above?

Thank you 

 

(defun c:avnumber (/ txttmp no# ss obj)
(vl-load-com)
(initget 1)
(setq no# (getint "\nEnter number: ")
); setq
(setvar "errno" 0)
(while
(while
(and
(/= (getvar "errno") 52) (not ss)
); and
(setq ss (ssget "+.:S" '((0 . "*TEXT"))))
); while
(setq obj (vlax-ename->vla-object (ssname ss 0))
no#t (strcat "0" (itoa no#))

); setntion to this request.

(while (< (strlen no#t) 3)
(setq no#t (strcat "0" no#t))
); while
(vlax-put obj 'textstring no#t)
(vlax-release-object obj)
(setq no# (1+ no#)
ss nil
); set
(setvar "errno" 0)
); while
)

0 Likes
223 Views
1 Reply
Reply (1)
Message 2 of 2

tracybrown
Participant
Participant

I added a lisp that does text and attributes but doesn't add the zero's as needed. Can someone help me make these two Lisp file into one file?

 

(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)
)

0 Likes