Author Topic: Text Renumbering  (Read 2711 times)

0 Members and 1 Guest are viewing this topic.

DanB

  • Bull Frog
  • Posts: 367
Text Renumbering
« on: December 06, 2004, 02:27:04 PM »
Does anyone have a routine that can renumber text strings? Example: string of dtext (or mtext) that reads "DS-1" or "DS-22" These are the callouts for our Drainage Structures. If we need to add an additional structure early on we need to renumber all of them. Late in the project we will add "DS-1A" or "DS-22A" if needed but not early in the project. I have a lisp that adds/subtracts values from a Block Attribute but wasn't sure of the approach on a text string. Can this be done and not recieve the value "28" when adding "+1" to "17" ("1" "+1" and "7" "+1").

Thanks,
Dan

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Text Renumbering
« Reply #1 on: December 06, 2004, 02:37:09 PM »
I believe someone has already done that Dan, did you try searching theswamp.
TheSwamp.org  (serving the CAD community since 2003)

DanB

  • Bull Frog
  • Posts: 367
Text Renumbering
« Reply #2 on: December 06, 2004, 02:41:29 PM »
I did a search for "renumbering" and I see the posts on renumbering block attributes, which I am able to do already..

M-dub

  • Guest
Text Renumbering
« Reply #3 on: December 06, 2004, 03:11:39 PM »
Do a search for APPEND and you should find something.  I did a search on Cadalyst and found something.

danny

  • Guest
Text Renumbering
« Reply #4 on: December 06, 2004, 03:27:03 PM »

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Text Renumbering
« Reply #5 on: December 06, 2004, 03:33:40 PM »
Qick and dirty, very little error trapping and doesn't do MTEXT, but it'll get you started. :D
Code: [Select]

(defun c:add2txt (/ ent txt_str num str)

  (if (setq ent (car (entsel "\nPick a string: ")))

(progn
 (setq ent (entget ent))

 (if (= (cdr (assoc 0 ent)) "TEXT")
(progn
 (setq txt_str (cdr (assoc 1 ent)))

 (setq num
(itoa
  (1+
(atoi
  (substr
txt_str
(+ (vl-string-position (ascii " ") txt_str nil T)
2
)
)
  )
)
  )
)

 (setq str
(substr txt_str
1
(1+ (vl-string-position (ascii " ") txt_str))
)
)

 (setq ent
(subst (cons 1 (strcat str num)) (assoc 1 ent) ent)
)
 (entmod ent)
 (princ)
 )
;else
(alert "that wasn't (D)TEXT")
)
 )
)
  )
TheSwamp.org  (serving the CAD community since 2003)

ELOQUINTET

  • Guest
Text Renumbering
« Reply #6 on: December 06, 2004, 03:55:23 PM »
go to show your stuff section second page and check out text and number thread by cab

DanB

  • Bull Frog
  • Posts: 367
Text Renumbering
« Reply #7 on: December 07, 2004, 07:43:08 AM »
Thanks for the help on this one. Think one of these should do the trick.

Dan