×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Text Add/Substract lisp routine

Text Add/Substract lisp routine

Text Add/Substract lisp routine

(OP)
Hi,

Can anybody point me to a lisp routine that will add/substract an amount from a text line?

Thank you,

Roberttx.
 

RE: Text Add/Substract lisp routine

Hi...

You can be more explicit?

And you can give an example me to have it more clear?. And thus to be able to help him

RE: Text Add/Substract lisp routine

I have one that works on regular text (not mtext), and if the text line begins with a number.  Email me at cabATeeiteamDOTcom if interested.

RE: Text Add/Substract lisp routine

(OP)
Hi,

I have a series of text labels with a content similar to:

Elev. 2548.52

I need to be able to add or substract a certain quantity (provided by the user) to this (or other) labels.
I figured out it has to get each entity's values, modify (numerically) and then update (or create) a label similar to the old one.

Thank you,
Roberttx

RE: Text Add/Substract lisp routine

Hi roberttx,

Assuming that each of your elevation text markers will ALL start with "ELEV. " and then contain a number, I have written the code below to do what I think you want. If you type in a positive number, it will add it to the existing number, if you type in a negative e.g. -25.50, it will subtract it from the original number and change your text to the new value. Let me know if this doesn't work the way that you want it to.

(defun c:ELCH ()
   (setq OLDTX (entsel "\nPick TEXT to change: "))
   (setq OLDDATA (entget (car OLDTX)))
   (setq OLDCD1 (cdr (assoc 1 OLDDATA)))
   (setq OLDEL (atof (substr OLDCD1 7)))
   (setq NEWAD (getreal "\nType in NUMBER to add (- to subtract): "))
   (setq NEWEL (+ OLDEL NEWAD))
   (setq NEWTX (strcat "ELEV. "(rtos NEWEL)))
   (setq EL (subst (cons 1 NEWTX) (assoc 1 OLDDATA) OLDDATA))
   (entmod EL)
   (princ)
);ends defun

Hope this helps,
Paul

RE: Text Add/Substract lisp routine

(OP)
Thanks, Paul! This will save my life for a few strokes less on the calculator.

Roberttx.

RE: Text Add/Substract lisp routine

Hey Roberttx,
If it is any help, this LISP program can be edited so that it will ask you for the number to add/subtract, and then allow you to start selecting as many labels as you want and it will change the label elevations by that amount.

If you want that option, let me know, and I'll try to "make it so".

Paul

RE: Text Add/Substract lisp routine

(OP)
Hi, Paul:

As a matter of fact, your program has been very helpful. I refined it a little bit, by changing the number to 2 decimals and making a loop for changing every number on the way of the cursor.

Thanks again,
Roberto.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources