Jump to content

"text changing" lisp needed.


fleshget

Recommended Posts

hi there,

 

i need a basic lisp about text changing..

 

the text is: 0+400.652

it change to: 0+700.652

 

lisp will add 300

 

some examples here:

 

0+600.000 -> 0+900.000

 

0+980.163 -> 1+280.163

 

 

there is a big intersection project, and i should add "300" meter to the KM texts.. so hard to doing it :/

 

sorry for poor english, thanks for advance :)

Link to comment
Share on other sites

This should do it:

(defun c:300 (/ ss)
(vl-load-com)
 (if (setq ss (ssget '((0 . "text") (1 . "0+*"))))
   (foreach str (mapcar 'vlax-ename->vla-object
            (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        )
     (vla-put-textstring
   str
   (strcat "0+" (rtos (+ 300 (atof (substr (vla-get-textstring str) 3))) 2 3))
     )
   )
 )
 (princ)
)

Link to comment
Share on other sites

This should do it:

(defun c:300 (/ ss)
(vl-load-com)
 (if (setq ss (ssget '((0 . "text") (1 . "0+*"))))
   (foreach str (mapcar 'vlax-ename->vla-object
            (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        )
     (vla-put-textstring
   str
   (strcat "0+" (rtos (+ 300 (atof (substr (vla-get-textstring str) 3))) 2 3))
     )
   )
 )
 (princ)
)

 

 

Not quite: 0+700 does not change to 1+000, but instead changes to 0+1000

Link to comment
Share on other sites

Ok....I've had my coffee and this appears to work 8)

 

(defun c:incsta    (/ int isreal lst newstr pos ss string)
 (vl-load-com)
 (if (setq ss    (ssget ":L" '((0 . "text") (1 . "*+*")))
       int    (getint "\nEnter increment amount: ")
     )
   (foreach str (mapcar 'vlax-ename->vla-object
            (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
        )
     (setq string (vla-get-textstring str)
       lst       (vl-string->list string)
       newstr (rtos (+ int (atof (apply 'strcat (mapcar 'chr (vl-remove 43 lst)))))
            2
            (if (setq isreal (vl-string-position 46 string))
              (strlen (substr string (+ 2 isreal)))
              0
            )
          )
       pos       (abs
            (+ (vl-string-position 43 string) (- (1+ (strlen newstr)) (strlen string)))
          )
       newstr (strcat (substr newstr 1 pos) "+" (substr newstr (1+ pos)))
       newstr (strcat (if (wcmatch newstr "+*")
                "0"
                ""
              )
              newstr
          )
     )
     (vla-put-textstring str newstr)
   )
 )
 (princ)
)

incsta.gif

Link to comment
Share on other sites

you save me from "3 days work". thanks so so so much for helping me! you made my day bro!

 

beer.jpg

 

e-beer for you :D

 

cheers bro!

 

EDIT:

 

hay mate, there is a problem.. how to use this lisp? :D

 

enter the command, and select the text(s), enter the encrement amount and then?

 

i'm using 2010 right now, and command bar says to me:

 

Command: incsta

Select objects: Specify opposite corner: 2 found

Select objects:
Enter increment amount: 500

Pick a point to increment selected text: ; error: bad argument value: 
non-negative: -2

 

the text is: 60+380.000

Link to comment
Share on other sites

.....

EDIT:

 

hay mate, there is a problem.. how to use this lisp? :D

 

enter the command, and select the text(s), enter the encrement amount and then?

 

i'm using 2010 right now, and command bar says to me:

 

Command: incsta

Select objects: Specify opposite corner: 2 found

Select objects:
Enter increment amount: 500

Pick a point to increment selected text: ; error: bad argument value: 
non-negative: -2

the text is: 60+380.000

 

Thanks for the E-Beer :) ... can you post the drawing you are working in? I tried that text string and it worked fine?

 

*EDIT....I think I may have fixed it...I reposted the code above. Give it a try and let me know.

Link to comment
Share on other sites

i tried right now mate..

 

60+380.000 to 60+480

 

60+380.001 to 60+480.001

 

the problem is ".000", i guess.. :)

 

I cannot duplicate your problem.... :huh: post your drawing and I'll try to get it sorted.

Link to comment
Share on other sites

I guess all is well with this?

 

INCSTA will only allow addition of whole number, i.e. 3 or 50 etc.

will not accept 3.100, or 50.1 etc.

 

I guess if the OP only wants to change by whole number not including any decimal part, then so be it.

 

I'd like the opportunity to change by any value.

Link to comment
Share on other sites

INCSTA will only allow addition of whole number, i.e. 3 or 50 etc.

will not accept 3.100, or 50.1 etc.

 

I guess if the OP only wants to change by whole number not including any decimal part, then so be it.

 

I'd like the opportunity to change by any value.

 

Change: (getint "\nEnter increment amount: ")

 

to (getreal "\nEnter increment amount: ")

 

or (getdist "\nEnter increment amount: ")

 

and it should work.

Link to comment
Share on other sites

Change: (getint "\nEnter increment amount: ")

 

to (getreal "\nEnter increment amount: ")

 

or (getdist "\nEnter increment amount: ")

 

and it should work.

 

 

Yes sir, it worked fine. Didn't dawn on this old head

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...