Text selection is reverse ?? first selected text is come at last. and last selected text come first. I Excel Sheet to put text on this. Plz Help.

Text selection is reverse ?? first selected text is come at last. and last selected text come first. I Excel Sheet to put text on this. Plz Help.

parwez.khan
Explorer Explorer
533 Views
3 Replies
Message 1 of 4

Text selection is reverse ?? first selected text is come at last. and last selected text come first. I Excel Sheet to put text on this. Plz Help.

parwez.khan
Explorer
Explorer

(defun c:TEDIT ()
(setq sset (ssget '((0 . "TEXT"))))
(setq sslen (sslength sset))
(while (> sslen 0)
(setq ent (entget (ssname sset (setq sslen (1- sslen)))))
(redraw (cdr (assoc -1 ent)) 3)
(prompt (strcat "\nOld text: " (cdr (assoc 1 ent))))
(setq nt (getstring T "\nNew text: "))
(redraw (cdr (assoc -1 ent)) 1)
(if (> (strlen nt) 0)
(entmod (subst (cons 1 nt) (assoc 1 ent) ent))
)
(princ)
)
)

0 Likes
Accepted solutions (1)
534 Views
3 Replies
Replies (3)
Message 2 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

Yes, that's an approach that counts down from the end of the selection set.  It can be done by counting up from the beginning instead, for example:

 

(defun c:TEDIT ()
  (setq sset (ssget '((0 . "TEXT"))))
  (setq i -1); index number [so that first pass uses i = 0]
  (repeat (sslength sset)
    (setq ent (entget (ssname sset (setq i (1+ i))))); start at index 0, count upward
....

Kent Cooper, AIA
0 Likes
Message 3 of 4

parwez.khan
Explorer
Explorer

Thanks bro. for Help.

0 Likes
Message 4 of 4

parwez.khan
Explorer
Explorer

Can you write full lisp with your condition please..

0 Likes