Jump to content

Recommended Posts

Posted

Hi,

For ex:"112+PL3/18+A36".This is my input string i want "PL3/18" and "A36" both are individually. Help me out this....

Posted

@ajithkumar.t I do not understand your question. Please provide a sample drawing with a before and after of what you would like to do.

  • Like 1
Posted

Does the string alway have the same format? xyx '+' PL12/34 '+' A12

 

Where there is a '+' to separate the portions of the text? My favourite way to separate strings like this is to use Lee Macs String to List LISP and here, use + as the separator which will return a list like this (112 PL3/18 A36) containing 3 list items

 

Use nth or car, cadr, caddr to extract the text strings.

 

This works really well if the text is all in the same format and you want to get the same part of the text string, a bit trickier if there is no constant separator or if there are a different number of string segments in it

  • Like 1
Posted

There was a make formula lisp somewhere that looks for the math operator + - / * etc, try googling.

  • Like 1
Posted

This is my code, but could not get output properly

(defun get-values-from-string (input-string)
  (setq pos1 (vl-string-search "+" input-string))
  (setq pos2 (vl-string-search "+" input-string (+ pos1 1)))
  (setq pos3 (vl-string-search "/" input-string))

  (if (and pos1 pos2)
      (list
       (strcase (substr input-string 1 (- pos1 1)))
       (if pos3
          (strcase (substr input-string (+ pos1 1) pos2))
         (strcase (substr input-string (+ pos1 1) (if pos2 pos2 (length input-string))))
          )
       (if pos3
          (strcase (substr input-string (+ pos2 1) pos2))
          (strcase (substr input-string (+ pos2 1)))
           )
      )
     (if pos3
         (list
          (strcase (substr input-string 1 (- pos3 1)))
         (strcase (substr input-string (+ pos3 1)))
         )
          (list (strcase input-string) "Not found" "Not found")
         )
     )
)

 

Posted
(setq pos1 (vl-string-search "+" input-string)))
(setq pos2 (vl-string-search "+" input-string (+ pos1 1)))
(setq pos3 (vl-string-search "/" input-string))
(setq pos1a (1+ pos1))
(setq pos2a (1+ pos2))
(setq pos3a (1+ pos3))
(setq cad1 (strcase (substr input-string (1+ pos1a) (1- (- pos2a pos1a)))));return "PL3/18"
(setq cad2 (strcase (substr input-string (1+ pos2a))));return "A36"

 

  • Like 1
Posted

SRTCASE converts lowercase letters to uppercase. In principle, it would not be necessary to use it.

  • Like 1
Posted (edited)

For ex:"112+PL3/18+A36". Doing some googling came across a couple of examples of why do this, one was get distance between 2 points and add subtract some fixed amounts to the distance. If this is the case can do a lisp that reflects this type of answer. Post a dwg showing why your doing this calc. Ie text as formula. 

 

For Autocad users you have CAL you can type formulas there to be used in a command like line, you use 'CAL note the apostrophe. An obvious one is (pt1 pt2)/ 2 3 4 etc.

 

Have a look at the help for CAL.

Edited by BIGAL

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