Code Red > AutoLISP (Vanilla / Visual)
Converting Text Strings into Values
MSTG007:
I am working with Navisworks, and within the measure tool, i can copy values out.
example
--- Code: ---(5941.400 ft, 1931.921 ft, 92.833 ft)
Grid Info: TL1-ZZ'13(-565)-TL1-2(164) : EL -8'-0" T/PR FDN (100)
--- End code ---
I am looking for a method which it can take the first row of text string and convert it to a coordinate (xyz), and draw a 6"/0.5 circle at that point.
Any ideas?
Thanks a bunch for any direction.
Lee Mac:
Assuming MTEXT:
* Obtain the text content from DXF group 1
* Parse the content into separate lines using "\\P" as a delimiter
* Remove non-numerical characters except spaces, hyphens, brackets & periods
* Use the read function to interpret the result as an AutoLISP list
* Use the resulting point list to create a circle (either using the CIRCLE command or entmake
MSTG007:
Thanks Lee, I will look into that.
BIGAL:
Not sure if looking at correct string.
--- Code: ---; thanks to Lee-mac for this defun
(defun csv->lst ( str / pos )
(if (setq pos (vl-string-position 32 str))
(cons (substr str 1 pos) (csv->lst (substr str (+ pos 2))))
(list str)
)
)
(setq lst (csv->lst "5941.400 ft, 1931.921 ft, 92.833 ft"))
("5941.400" "ft," "1931.921" "ft," "92.833" "ft")
(setq x (nth 0 lst) y (nth 2 lst) z (nth 4 lst))
--- End code ---
MSTG007:
Thanks for idea. I was on to something, then, I had the brainstorm of using a find and replace method that seemed to work out pretty well.
Navigation
[0] Message Index
[#] Next page
Go to full version