Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wire numbering and Cross reference ( Reverse Text)

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
cuasuavdd
663 Views, 12 Replies

Wire numbering and Cross reference ( Reverse Text)

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?

12 REPLIES 12
Message 2 of 13
pbejse
in reply to: cuasuavdd


@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?

 

 

Message 3 of 13
cuasuavdd
in reply to: cuasuavdd

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

Message 4 of 13
cuasuavdd
in reply to: cuasuavdd

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.

 

 

Message 5 of 13
pbejse
in reply to: cuasuavdd


@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

Message 6 of 13
pbejse
in reply to: pbejse

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

 

Message 7 of 13
cuasuavdd
in reply to: pbejse

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.
Message 8 of 13
pbejse
in reply to: cuasuavdd


@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.

 

Message 9 of 13
cuasuavdd
in reply to: pbejse

Thank you pbejse,
can you help with option attribute
Message 10 of 13
pbejse
in reply to: cuasuavdd


@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. 

Message 11 of 13
cuasuavdd
in reply to: pbejse

OK THANK YOU VERY MUCH.
Message 12 of 13
pbejse
in reply to: cuasuavdd


@cuasuavdd wrote:
Thank you pbejse,
can you help with option attribute

 

Try the attached lisp [REVSTR.lsp]

 

Command: revstr

 

HTH

Message 13 of 13
cuasuavdd
in reply to: pbejse

THANK YOU PBEJSE,

This is fastest help i ever got.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost