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

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
I guess I have an idea but without the ability to write codes for it . :-)

Can I divide the txt file into three or four files by using lisp which is going to select a txt file and cut a 50.000 lines of strings of the file and paste them ( I mean write them to a txt file with another name and remove them from the source file )

Otherwise should I look for Autodesk program that could do the easily (3D civil or MAP or etc ....) I have no idea which is the right one .

Hope you bear with me guys you've been so kind with me ...

Thank you so much

dgorsman

  • Water Moccasin
  • Posts: 2437
Anything more than a few thousand (literally, not tens/hundreds of thousands) points are better handled in dedicated point cloud software.  They use all sorts of tricks to speed up processing and making useable.  Newer versions of AutoCAD and related products include the Faro engine, if that helps.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
<post removed>
« Last Edit: November 09, 2011, 08:14:24 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Hacked together to divide the file:

Code: [Select]
(defun c:dividefile ( / fn i j l lines rf wf )

    (setq lines 50000) ;; Number of Lines for each file
   
    (if
        (and
            (setq fn (getfiled "" "" "txt" 16))
            (setq rf (open fn "r"))
            (setq fn (fnsplitl fn)
                  fn (strcat (car fn) (cadr fn))
            )
        )
        (progn
            (setq i 0)
            (while (setq l (read-line rf))
                (if (setq wf (open (strcat fn "_" (itoa (setq i (1+ i))) ".txt") "w"))
                    (progn
                        (setq j 1)
                        (write-line l wf)
                        (while (and (<= (setq j (1+ j)) lines) (setq l (read-line rf)))
                            (write-line l wf)
                        )
                        (close wf)
                    )
                )
            )
            (close rf)
        )
    )
    (princ)
)

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Not sure if Daniel made an AutoCAD version of this?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
To update my earlier code to incorporate Alanjt & Jeff_M's suggestions:

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))
                (entmake (list '(0 . "POINT") (read (strcat "( 10 " l ")"))))
            )
            (setq f (close f))
        )
    )
    (princ)
)

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
<post removed>
« Last Edit: November 09, 2011, 08:14:42 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Coder

  • Swamp Rat
  • Posts: 827
I just wrote a program (in C++) to add a paren before and after the coordinates and tested it out on a file with 10,000 lines in it.

Quote
process-coordinate-file.exe -i input_me.txt -o out.txt
This operation took: 0.0065025 seconds.

Not sure if that would help you at all but you are more than welcome to have it if you want it.

You're too kind , of course I would like ti have it and I may in need to know how load it and run it as well .

many thanks.

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
<post removed>
« Last Edit: November 09, 2011, 08:14:56 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Coder

  • Swamp Rat
  • Posts: 827
I did not get what you mean that well with paren , Does it mean that I have to divide the txt file that contains the coordinates or so ( I did not get it ).

Won't you program import the coordinates directly from file to Autocad as points ?

I am sorry for not being able to understand your point . :oops:

Many thanks

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
<post removed>

« Last Edit: November 09, 2011, 08:15:08 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Coder

  • Swamp Rat
  • Posts: 827
That's alright.

No, you guys were having a hard time reading and processing that many items in the file so I asked you if you would like me to write you a program in C++ to do that processing for you...so all you had to do was to read the file into your program (saving the processing time/steps).  I suggested this because I can process a huge amount of data in milliseconds with C++ (get the data ready for you to read with lisp).

If you don't want the program that's okay too.

That sounds great , and I do looking forward to see my problem disappear with long txt file with coordinates with Autocad .

Waiting for your kind reply and application .

Thank you

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
<post removed>
« Last Edit: November 09, 2011, 08:12:46 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Coder

  • Swamp Rat
  • Posts: 827
According to what I understood from you that you would divide the txt file into another separate more files to reduce the quantity of coordinates into each one , but I think this is not the issue at the moment .

To speed up the process of importing coordinates and insert them as points at every coordinate of it , is what I am looking for .

Dividing file into pieces is not that important since Lee supported us with excellent one .

Your zip file hold only one file (index.php) only and there is not anything else .

Thank you so much for your time and for interests .

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
<post removed>
« Last Edit: November 09, 2011, 08:13:34 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org