Jump to content

Add or subtract from a station label with alpha-numeric text


JPayne

Recommended Posts

This is a little hairy - I have about 4000 labels with Stations and a weld number along a pipeline and the stations are all going to increase or decrease depending on new data being provided.

 

Here are a few random labels:

0+57 MLC-25

748+94 ATI-16

 

Only the stationing needs to be changed - so if they all increase by 6, it would be 0+63 MLC-25 or 749+00 ATI-16.

 

Is there a lisp out there that will do that? Assuming I need to remove the +, modify the number and place the + back in.

 

Thanks for any help!

Link to comment
Share on other sites

I have attached a LISP program I used to use. I didn't write it, and credit to the original writer is in the code itself. This should work on single line text. If you have attributes or mtext, it will likely need some modification.

 

Also, welcome to CadTutor.

CS.LSP

Link to comment
Share on other sites

my 2 cents:


(setq inc (getint "\Enter increment with + / decrement with - : "))
(setq 
strRep (vl-string-left-trim "0123456789" oldLabel))
(setq strFst 
(vl-string-trim strRep oldLabel))
(setq strEnd (vl-string-left-trim 
"+0123456789" strRep))
(setq sign 
(if (minusp inc) "-" "+"))
(setq 
decs 
(if (= "-" sign)
(- (atoi strRep) (abs inc) )
(+ (atoi 
strRep) (abs inc) ) ))


(setq newLabel
(if (= (fix (/ decs 100)) 1)
 (strcat (itoa (+ 
(atoi strFst) (fix (/ decs 100)))) sign "00" strEnd)
(strcat strFst 
sign (itoa decs) strEnd)))

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