ajithkumar.t Posted February 28 Posted February 28 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.... Quote
pkenewell Posted February 28 Posted February 28 @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. 1 Quote
Steven P Posted February 28 Posted February 28 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 1 Quote
BIGAL Posted February 28 Posted February 28 There was a make formula lisp somewhere that looks for the math operator + - / * etc, try googling. 1 Quote
ajithkumar.t Posted February 29 Author Posted February 29 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") ) ) ) Quote
robierzo Posted February 29 Posted February 29 (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" 1 Quote
robierzo Posted February 29 Posted February 29 SRTCASE converts lowercase letters to uppercase. In principle, it would not be necessary to use it. 1 Quote
BIGAL Posted February 29 Posted February 29 (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 February 29 by BIGAL Quote
Recommended Posts
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.