Dear All,
i got drawing with wire number like with 2 types like this: 300AB, AB.
and cross reference like this [300AB], [AB].
i want a code of autolisp change from 300AB to 300BA, AB to BA, [300AB] to [300BA] and [AB] to [BA]
I want to change current all text or mtext or value of attribute from form as up there to just reverse two last characters.
i have reverse lisp as follow:
(defun c:revtext ()
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(command "UNDO" "G")
(setq sset (ssget '((0 . "TEXT"))))
(if sset
(progn
(setq num (sslength sset) itm 0)
(while (< itm num)
(setq hnd (ssname sset itm))
(setq ent (entget hnd))
(setq str (cdr (assoc 1 ent)))
(setq new "")
(setq pos (strlen str))
(repeat pos
(setq let (substr str pos 1))
(setq new (strcat new let))
(setq pos (1- pos))
)
(setq ent (subst (cons 1 new)(assoc 1 ent) ent))
(entmod ent)
(setq itm (1+ itm))
)
(princ ", Done.")
)
)
(command "UNDO" "E")
(setvar "CMDECHO" cmdecho)
(princ)
)
can you all help me?
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
Solved by pbejse. Go to Solution.
@cuasuavdd wrote:
Dear All,
i got drawing with wire number like with 2 types like this: 300AB, AB.
and cross reference like this [300AB], [AB].
i want a code of autolisp change from 300AB to 300BA, AB to BA, [300AB] to [300BA] and [AB] to [BA]
I want to change current all text or mtext or value of attribute from form as up there to just reverse two last characters.
can you all help me?
Will that be always the case?
What about
300AB44 -> 300BA44?
or even
AB300BA -> BA300AB?
Text or Mtext or attribute we select will be always in type " nnntt or tt or [nnntt] or [tt] "
t = text
n = number
example:
- [300AB] to [300BA]
- [ab] to [ba]
- 450CX to 450XC
- CX to XC
Thank you very much pbejse,
See attached for example block with attribute for change.
i think i just need click to position of attribute to change value of attribute or change value of all attributes in region limited by mouse.
@cuasuavdd wrote:
Text or Mtext or attribute we select will be always in type " nnntt or tt or [nnntt] or [tt] "
t = text
n = number
example:
- [300AB] to [300BA]
- [ab] to [ba]
- 450CX to 450XC
- CX to XC
(defun c:revtxt (/ _reverseAlpha sset pstr nstr) ;;; pBe JAn 2013 ;;; (vl-load-com) (defun ReverseOnlyAlpha (str char-set / st) (setq st str) (setq str (vl-string-trim char-set str)) (vl-string-subst (vl-list->string (reverse (vl-string->list str)) ) str st ) ) (if (setq sset (ssget '((0 . "TEXT,MTEXT")))) (repeat (setq i (sslength sset)) (setq e (vlax-ename->vla-object (ssname sset (setq i (1- i))))) (princ (strcat "\n" (setq pstr (vla-get-textstring e)) " -> " (setq nstr (ReverseOnlyAlpha pstr "[0123456789]")) ) ) (vla-put-TextString e nstr ) ) ) (princ) )
HTH
The code above can be simpler, bit i wrote it in such a way its not limited to Two characters at the condition
As for the ATTRIBUTE, will that be all attdef in single block? or is it just one attdef per block?
We can incorporate an option for that on the code above, but i'm not sure about the conditions as of yet.
HTH
@cuasuavdd wrote:
Thank you very much pbejse,
See attached for example block with attribute for change.
i think i just need click to position of attribute to change value of attribute or change value of all attributes in region limited by mouse.
Well, would you settle for a seperate routine for that? or if you want we can still add option for attrib on the previous code but it will require some "imagineering" on my part to come up with a suitable solution.
@cuasuavdd wrote:
Thank you pbejse,
can you help with option attribute
OK then, think i have an idea how to approach this issue. I'll post the code later.
@cuasuavdd wrote:
Thank you pbejse,
can you help with option attribute
Try the attached lisp [REVSTR.lsp]
Command: revstr
HTH