Author Topic: What's the fastest way to transfer string of coordinates to list of points ?  (Read 5954 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Hi everyone .

I have hundreds of coordinate points that are existed in a .txt file and I want to read them to lisp file to insert for
each coordinate as a point or block , so I wrote some codes .

Could and would you please help me with it ?  :oops:

Code: [Select]
(if (setq fl (getfiled "Select File" (getvar 'dwgprefix) "txt" 8))
  (progn
    (setq f (open fl "r"))
    (setq r (read-line f)) ;; =>  "15.53215 7.451254 -10.4551"
    .....
    ............
    ..................

Thank you so much guys

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Perhaps not the fastest program, but one that is already written  :-P

http://lee-mac.com/ptmanager.html

pBe

  • Bull Frog
  • Posts: 402
Hi everyone .

I have hundreds of coordinate points that are existed in a .txt file and I want to read them to lisp file to insert for
each coordinate as a point or block , so I wrote some codes .

Could and would you please help me with it ?  :oops:

Code: [Select]
(if (setq fl (getfiled "Select File" (getvar 'dwgprefix) "txt" 8))
  (progn
    (setq f (open fl "r"))
    (setq r (read-line f)) ;; =>  "15.53215 7.451254 -10.4551"
    .....
    ............
    ..................

Thank you so much guys


(read (strcat "(" r ")")

Coder

  • Swamp Rat
  • Posts: 827
Perhaps not the fastest program, but one that is already written  :-P

http://lee-mac.com/ptmanager.html

I am sorry , your program did not work for me and I don't know why !!!!

I selected the txt file and selected point option from the list of your program and it did nothing and the pdmode is equal 66

Can you please help me with it ?

forms of the coordinates
Quote
0.155750 5.085015 -4.799957
0.152540 5.087977 -4.799713

Coder

  • Swamp Rat
  • Posts: 827
(read (strcat "(" r ")")

Thanks , that looks interesting . :-)


Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Perhaps not the fastest program, but one that is already written  :-P

http://lee-mac.com/ptmanager.html

I am sorry , your program did not work for me and I don't know why !!!!

I selected the txt file and selected point option from the list of your program and it did nothing and the pdmode is equal 66

Can you please help me with it ?

forms of the coordinates
Quote
0.155750 5.085015 -4.799957
0.152540 5.087977 -4.799713

Did you select the correct data delimiter (in your case 'Space')?

Coder

  • Swamp Rat
  • Posts: 827
Perhaps not the fastest program, but one that is already written  :-P

http://lee-mac.com/ptmanager.html

I am sorry , your program did not work for me and I don't know why !!!!

I selected the txt file and selected point option from the list of your program and it did nothing and the pdmode is equal 66

Can you please help me with it ?

forms of the coordinates
Quote
0.155750 5.085015 -4.799957
0.152540 5.087977 -4.799713

Did you select the correct data delimiter (in your case 'Space')?

Yes that's what I missed , and although the computer is hanging because the coordinates file is about 100 MB and I am almost sure the coordinates are more than 250.000 points .

How to run that huge file of coordinates ?? ( big question ) :-)

Thank you

efernal

  • Bull Frog
  • Posts: 206
using bPe suggestion:


(SETQ r "10.0 10.0 0.0")
(ENTMAKE (LIST (CONS 0 "POINT") (CONS 10 (READ (STRCAT "(" r ")")))))
e.fernal

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Using pBe's suggestion:

Code: [Select]
(defun c:test ( / f l )
    (if
        (and
            (setq f (getfiled "" "" "txt" 16))
            (setq f (open f "r"))
        )
        (progn
            (while (setq l (read-line f))
                (entmakex (list (cons 0 "POINT") (cons 10 (read (strcat "(" l ")")))))
            )
            (setq f (close f))
        )
    )
    (princ)
)

Coder

  • Swamp Rat
  • Posts: 827
I saw lots of points drawn in the screen but and during that process I have received a message and it says ( Autocad exceeding system memory ) not
the exact message but the almost the same meaning , and before finishing prompt a message at the command line : unwinned and unexceptional error .

and at last Autocad report to exit .  :ugly:

OMG I could't succeed the trick . :cry:

Thanks for all the hard work and your time guys .

( I think there is no chance to do the trick with things with these kind huge coordinates file to points ( but hope somebody would break through it and do it ))  :-)

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Try breaking down the file into multiple smaller files, then import each one.

100MB sounds absolutely mahoosive though  :-o

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Code: [Select]
                (entmakex (list (cons 0 "POINT") (cons 10 (read (strcat "(" l ")")))))
It's been quite a while since I've done any serious work in lisp, so maybe I've missed this discussion......why the use of ENTMAKEX instead of ENTMAKE? From the help file:
Quote
Warning Objects and entities without owners are not written out to DWG or DXF files. Be sure to set an owner at some point after using entmakex.
Could this be the cause of Acad failing with so many un-owned objects being added? (Probably not, just caught my eye as a possibility.)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Code: [Select]
                (entmakex (list (cons 0 "POINT") (cons 10 (read (strcat "(" l ")")))))
It's been quite a while since I've done any serious work in lisp, so maybe I've missed this discussion......why the use of ENTMAKEX instead of ENTMAKE? From the help file:
Quote
Warning Objects and entities without owners are not written out to DWG or DXF files. Be sure to set an owner at some point after using entmakex.
Could this be the cause of Acad failing with so many un-owned objects being added? (Probably not, just caught my eye as a possibility.)
To build on Jeff's comment, since you are already using strcat, you could also include your dxf 10 code in there, instead of using cons once the list is created.

Code: [Select]
(entmake (list '(0 . "POINT") (read (strcat "( 10 " l ")"))))

Code: [Select]
(benchmark '(
(entmakex (list (cons 0 "POINT") (cons 10 (read (strcat "(" l ")")))))
(entmakex (list '(0 . "POINT") (read (strcat "( 10 " l ")"))))
(entmake (list '(0 . "POINT") (read (strcat "( 10 " l ")"))))
            )
)

Code: [Select]
    (ENTMAKE (LIST (QUOTE (0 . "POINT"))...).....1061 / 1.16 <fastest>
    (ENTMAKEX (LIST (QUOTE (0 . "POINT")...).....1155 / 1.07
    (ENTMAKEX (LIST (CONS 0 "POINT") (CO...).....1232 / 1 <slowest>
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
The code was hastily written, but that's no excuse - good point guys, great suggestions.