ASCPOINT

Please help me modify the lisp program for importing the data from .txt
This is how data looks like:
1,2.117.42899999954,-2147.81300000008
1,2150.03500000015,-2165.32400000002 1,2167.15799999982,-2143.45299999975 1,2160.74000000022,-2134.02300000004 1,2122.4879999999,-2111.14400000032 1,2105.6129999999,-2140.65000000037 1,2108.7790000001,-2142.45999999996 2,1486.67200000025,-2271.01699999999 2,1489.32699999958,-2274.32400000002 2,1480.68499999959,-2280.36199999973 2,1483.32600000035,-2284.17700000014 2,1479.88399999961,-2287.61600000039 2,1475.44099999964,-2283.92399999965 3,705.259999999776,-1546.78299999982 3,690.061999999918,-1564.27500000037 3,700.770999999717,-1573.26499999966 3,702.75299999956,-1570.98400000017 3,704.569000000134,-1572.57299999986 3,716.736999999732,-1558.49500000011 3,714.792000000365,-1556.73099999968 4,2390.11199999973,-2496.71399999969 4,2387.92300000042,-2499.76599999983 4,2383.98599999957,-2496.94199999981 4,2378.84100000001,-2504.11500000022 4,2387.63300000038,-2510.42200000025 4,2392.74100000039,-2503.29999999981 4,2397.65299999993,-2506.82299999986 4,2399.87899999972,-2503.71899999958
the first number is object code, second is X coordinate and third is Y coordinate I need program to draw SEPERATE objects with data like that.
Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Firstly the data has an error in the first line 2.117.428999999954 should read 2117.428999999954 The first decimal is incorrect. Next consider the attached lisp routine:
(defun initiate () (setq filename "data.txt" fileopen (open (findfile filename) "r") ) ) (defun c:separate () (setq line (read-line fileopen) delimiter1 (vl-string-search "," line) delimiter2 (vl-string-search "," line (1+ delimiter1)) dat1 (substr line 1 delimiter1) dat2 (substr line (+ 2 delimiter1) (1- (- delimiter2 delimiter1))) dat3 (substr line (+ 2 delimiter2)) codeno dat1 coord (list (distof dat2) (distof dat3)) ) )
This routine assumes your data file is named data.txt . You can change this by changing the filename variable. Assuming the data file is in your AutoCAD search path, to run this load it and then enter "separate" without the quotation marks. The first line of the data file will be broken up into 5 entities dat1, dat2, dat3, codeno & coord. dat1=codenoฺt1. dat2=xcoordinate as a string. dat3=ycoordinate as a string & finally coord is the list of your x and y coordinates which can be used by AutoCAD. for example if you wish to draw a line from the first coordinate point type in "l" to start the line command and then !coord to use the coordinate as the first point. To retrieve subsequent data lines just run "separate" again. When you are done enter (close fileopen) at the command line. To start over enter (close fileopen) then (initiate) then "separate".

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Give this a try........

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Hit the button too fast.....here's the code:
;|requires data file in the format of: objectnumber, x-coordinate,y-coordinate" Example: 1,2117.42899999954,-2147.81300000008 1,2150.03500000015,-2165.32400000002 1,2167.15799999982,-2143.45299999975 1,2160.74000000022,-2134.02300000004 1,2122.4879999999,-2111.14400000032 1,2105.6129999999,-2140.65000000037 1,2108.7790000001,-2142.45999999996 2,1486.67200000025,-2271.01699999999 2,1489.32699999958,-2274.32400000002 2,1480.68499999959,-2280.36199999973
by Jeff Mishler March 11, 2006 |; (defun c:data2plines (/ dat dat_list ffile fname idx master tmp osmode) ;;Str2List function by John Uhden as posted to the Adesk newsgroups (defun Str2List (str pat / i j n lst) (cond ((/= (type str) (type pat) 'STR)) ((= str pat) '("")) (T (setq i 0 n (strlen pat) ) (while (setq j (vl-string-search pat str i)) (setq lst (cons (substr str (1+ i) (- j i)) lst) i (+ j n) ) ) (reverse (cons (substr str (1+ i)) lst)) ) ) ) (if (setq fname (getfiled "Data File Selection" "" "" 0)) (progn (setq ffile (open fname "R") idx 1) (while (setq dat (read-line ffile)) (setq dat_list (str2list dat ",")) (setq master (cons (list (atoi (car dat_list)) (atof (cadr dat_list)) (atof (caddr dat_list)) ) master)) ) (close ffile) (setq master (reverse master) osmode (getvar "osmode")) (setvar "osmode" 0) (while master (setq tmp (vl-remove-if-not '(lambda (x) (= (car x) idx) ) master)) (command ".pline") (mapcar '(lambda (x) (command (cdr x)) ) tmp ) (command "c") (setq master (vl-remove-if '(lambda (x) (= (car x) idx) ) master) idx (1+ idx) ) ) (setvar "osmode" osmode) ) ) (princ) )

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
thank you very much, both
Jeff, could you please tell me how to speed up your excellent program because I have got more than 130000 objects!!
Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On 22 Mar 2006 03:07:02 -0800, snipped-for-privacy@mail.ru wrote:

If you find acad is just tooooooooooooo slow with a lot of points, try using Terramodel. It was made for this.
Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Jeff, there are two problems with your program; it doesnt work if the start object code is NOT = 1 and if any object is skipped. Could you please modify it so it would work with this data file:
4,2390.11199999973,-2496.71399999969 4,2387.92300000042,-2499.76599999983 4,2383.98599999957,-2496.94199999981 4,2378.84100000001,-2504.11500000022 4,2387.63300000038,-2510.42200000025 4,2392.74100000039,-2503.29999999981 4,2397.65299999993,-2506.82299999986 4,2399.87899999972,-2503.71899999958 5,2407.73000000045,-2495.37200000044 5,2404.74700000044,-2493.23199999984 5,2405.61400000006,-2492.02300000004 5,2401.83299999963,-2489.31099999975 5,2401.01300000027,-2490.45299999975 5,2392.84300000034,-2484.59300000034 5,2399.3200000003,-2475.56199999992 5,2399.92200000025,-2474.83999999985 5,2413.18200000003,-2487.77099999972 7,2436.24799999967,-2517.29600000009 7,2444.91199999955,-2526.40799999982 7,2440.58999999985,-2534.93599999975 7,2429.57899999991,-2523.6370000001 10,2363.37200000044,-2591.44199999981 10,2373.02099999972,-2596.73699999973 10,2370.43300000019,-2601.45399999991 10,2364.76099999994,-2598.34200000018 10,2365.98000000045,-2596.12200000044 10,2362.00200000033,-2593.93900000025 130648,-2735.276639238,-4434.65681617334 130648,-2738.65501988586,-4427.06130247004 130648,-2723.21111124661,-4420.1920630578 130648,-2719.83273059782,-4427.7875767611 130649,-2719.83273059782,-4427.78757676203 130649,-2723.21111124754,-4420.19206305873 130649,-2707.7232588781,-4413.30327807646 130649,-2704.34487823118,-4420.89879177883 130650,1553.75697861798,-844.791826856323 130650,1547.61300138664,-836.519349547103 130650,1525.96010449994,-852.329735823907 130650,1526.57496948354,-855.248041311279 130650,1543.32974211592,-864.463764600456 130651,1547.61300138664,-836.519349547103 130651,1563.80157137383,-824.496082309633 130651,1569.94554860331,-832.768559616059 130651,1553.75697861798,-844.791826856323
being slow is not actually a big problem, I can live with that
Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
On 23 Mar 2006 05:13:26 -0800, snipped-for-privacy@mail.ru wrote:

I sometimes have to visualize in 3D a surface having as many as 3/4 million elevation points. " Living with that " in acad would represent a significant portion of my life.
If you do find you need help getting around this at some future point - hahaha - post again.
Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Hi, I thought you'd forgotten about this since there was no response for 11 days. I'll take a look at it in the next day or two.
Would you be willing to send me a complete point file? If so, send to: jmishlerATsbcglobalDOTnet adjust the AT & DOT accordingly
Jeff

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Hi orangeKDS, I just looked and realized it wasn't too hard of a fix. Here's a new lisp that works with any leading number, in any sequence (providing the same number sequence is not repeated, otherwise they will be all created as 1 pline).
This one also should be much quicker.
Jeff
;|requires data file in the format of: objectnumber, x-coordinate,y-coordinate" Example: 1,2117.42899999954,-2147.81300000008 1,2150.03500000015,-2165.32400000002 1,2167.15799999982,-2143.45299999975 1,2160.74000000022,-2134.02300000004 1,2122.4879999999,-2111.14400000032 1,2105.6129999999,-2140.65000000037 1,2108.7790000001,-2142.45999999996 2,1486.67200000025,-2271.01699999999 2,1489.32699999958,-2274.32400000002 2,1480.68499999959,-2280.36199999973
by Jeff Mishler March 11, 2006 |; (defun c:data2plines (/ dat dat_list ffile fname idx master tmp mspace coords pline) ;;Str2List function by John Uhden as posted to the Adesk newsgroups (defun Str2List (str pat / i j n lst) (cond ((/= (type str) (type pat) 'STR)) ((= str pat) '("")) (T (setq i 0 n (strlen pat) ) (while (setq j (vl-string-search pat str i)) (setq lst (cons (substr str (1+ i) (- j i)) lst) i (+ j n) ) ) (reverse (cons (substr str (1+ i)) lst)) ) ) ) (if (setq fname (getfiled "Data File Selection" "" "" 0)) (progn (vl-load-com) (setq ffile (open fname "R")) (while (setq dat (read-line ffile)) (setq dat_list (str2list dat ",")) (setq master (cons (list (atoi (car dat_list)) (atof (cadr dat_list)) (atof (caddr dat_list)) ) master)) ) (close ffile) (setq master (reverse master) mspace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setvar "osmode" 0) (while master (setq idx (car (car master)) coords nil) (setq tmp (vl-remove-if-not '(lambda (x) (= (car x) idx) ) master)) (setq coords (apply 'append (mapcar 'cdr tmp))) (setq pline (vlax-invoke mspace 'addlightweightpolyline coords)) (vla-put-closed pline :vlax-true) (setq master (vl-remove-if '(lambda (x) (= (car x) idx) ) master) ) ) (vla-zoomextents (vlax-get-acad-object)) ) ) (princ) )

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Hi, could you do one more modification, hope its not too hard:
the new data would look like this:
LineCode, Xcoordinate_of_first_dot, Ycoordinate_of_first_dot, ASCIItext, line density LineCode, Xcoordinate_of_next_dot, Ycoordinate_of_next_dot,, line density
this time Line must NOT be closed, I have tried modifying your program like this: (vla-put-closed pline :vlax-true) to (vla-put-closed pline :vlax-false)
and it works, but how can I add ASCII text next to line and change its density?
Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Please email me a small sample data file along with the desired results in a dwg file and I'll see what i can do.
jmishlerATsbcglobal.net

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
If you take your *.txt file and rename it to *.csv it will open in Excel. If you add two columns in Excel, Z coordinate and Description could make use of our survey program: http://www.caddproductivity.com/survey.htm
It's an add-on VB program which imports and exports survey data to & from AutoCAD. The download is fully functional and free to use for 30 days.
From the website:      Survey Import and Export
The Survey program works to Import and Export your survey data to and from AutoCADฎ. The configurable interface makes matching survey data descriptions (as assigned in the field) to text, blocks or points, straightforward.
Import Survey Data: Survey data is read from *.txt or *.csv file(s) so the user may match the data to blocks, text or points per unique description. The selected descriptions are inserted in to the drawing per the symbols specified (with the option of coordinate marker blocks, which display coordinate & other data). Import Survey Data works with the supplied database (CADD.mdb included with the program's installation file) to support multiple (saved) import configurations.
Interactive Image: www.caddproductivity.com/surveyimage.htm
Export Survey Data: Blocks and text are exported from the drawing to a text file (containing X, Y, Z, Index and Description) via a configurable interface.
Interactive Image: www.caddproductivity.com/surveyimageexport.htm
Hope this helps, snipped-for-privacy@caddproductivity.com
> > snipped-for-privacy@mail.ru wrote:

Add pictures here
โœ–
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.