TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HOSNEYALAA on August 27, 2019, 10:32:51 AM
Title:
If possible help with the conversion "13204.74087\\P16224.7943\\P2.56"
Post by:
HOSNEYALAA
on
August 27, 2019, 10:32:51 AM
Hello all
If I have this sentence
"13204.74087\\P16224.7943\\P2.56"
How can i turn it into
(13204.74087 16224.7943 2.56)
Thanks in advance
Title:
Re: If possible help with the conversion "13204.74087\\P16224.7943\\P2.56"
Post by:
ronjonp
on
August 27, 2019, 11:18:43 AM
Something like this:
Code - Auto/Visual Lisp:
[Select]
(
read
(
strcat
"("
(
vl-string-translate
"
\\
P"
" "
"13204.74087
\\
P16224.7943
\\
P2.56"
)
")"
)
)
Or do a search for 'parse string' .. there are numerous examples.
Probably most used: http://www.lee-mac.com/stringtolist.html
Title:
Re: If possible help with the conversion "13204.74087\\P16224.7943\\P2.56"
Post by:
Tharwat
on
August 27, 2019, 11:25:34 AM
Hi,
Your string must have been retrieved from Mtext object. :wink: so you can use the following function:
Code - Auto/Visual Lisp:
[Select]
(
defun
_peelstring
(
string del
/
str pos lst
)
;; Tharwat - date: 07.Nov.2015 ;;
(
while
(
setq
pos
(
vl-string-search
del string
0
)
)
(
setq
str
(
substr
string
1
pos
)
string
(
substr
string
(
+
pos
(
1+
(
strlen
del
)
)
)
)
)
(
and
str
(
/=
str
""
)
(
setq
lst
(
cons
str lst
)
)
)
)
(
and
string
(
/=
string
""
)
(
setq
lst
(
cons
string lst
)
)
)
(
reverse
lst
)
)
The return would be in a string format:
Code - Auto/Visual Lisp:
[Select]
(
_peelstring
"13204.74087
\\
P16224.7943
\\
P2.56"
"
\\
P"
)
Title:
Re: If possible help with the conversion "13204.74087\\P16224.7943\\P2.56"
Post by:
HOSNEYALAA
on
August 28, 2019, 01:57:23 AM
Thank you so much
ronjonp
Tharwat
The solution is good
And it works great
Thank you
Title:
Re: If possible help with the conversion "13204.74087\\P16224.7943\\P2.56"
Post by:
Tharwat
on
August 28, 2019, 04:58:28 AM
You're welcome anytime.