PDA

View Full Version : help extract pile coordinates



chipikiri
2nd Mar 2007, 09:12 pm
I need help on how to extract pile coordinates to excel or spreadsheets, or anything that works and is quicker than just individual pile coordinates.

Plse, help!! i have about 446 piles.:(

lpseifert
2nd Mar 2007, 09:28 pm
How are your piles represented on the dwg? If the are blocks you can use EATTEXT (Extended ATTribute EXtract).

chipikiri
2nd Mar 2007, 09:35 pm
they are normal circles, cad 2007. thanks in advance

chipikiri
2nd Mar 2007, 09:50 pm
any help out there?

CarlB
2nd Mar 2007, 09:52 pm
Here's a real simple lisp routine, writes to a text file in "x,y" format. You could give the file name an ".csv" extension then open with Excel


(princ "\nType PTF to start")
(defun c:ptf ()
(setq FileName (getstring "\nEnter file name for coordinate output: "))
(setq f1 (open FileName "w"))
(princ "\nSelect circles to write to file: ")
(setq PointSet (ssget '((0 . "CIRCLE"))))
(setq EntNum 0)
(repeat (sslength PointSet)
(setq ename (ssname PointSet EntNum))
(setq PtCoord (cdr (assoc 10 (entget ename))))
(setq xval (rtos (car PtCoord) 2 4)
yval (rtos (cadr PtCoord) 2 4)
zval (rtos (caddr PtCoord) 2 4)
PtString (strcat xval "," yval "," zval)
)
(write-line PtString f1)
(setq EntNum (1+ EntNum))
)
(close f1)
(princ)
)

chipikiri
2nd Mar 2007, 10:19 pm
where is my .csv file saved, can not find it?


Here's a real simple lisp routine, writes to a text file in "x,y" format. You could give the file name an ".csv" extension then open with Excel


(princ "\nType PTF to start")
(defun c:ptf ()
(setq FileName (getstring "\nEnter file name for coordinate output: "))
(setq f1 (open FileName "w"))
(princ "\nSelect circles to write to file: ")
(setq PointSet (ssget '((0 . "CIRCLE"))))
(setq EntNum 0)
(repeat (sslength PointSet)
(setq ename (ssname PointSet EntNum))
(setq PtCoord (cdr (assoc 10 (entget ename))))
(setq xval (rtos (car PtCoord) 2 4)
yval (rtos (cadr PtCoord) 2 4)
zval (rtos (caddr PtCoord) 2 4)
PtString (strcat xval "," yval "," zval)
)
(write-line PtString f1)
(setq EntNum (1+ EntNum))
)
(close f1)
(princ)
)

Starkey
2nd Mar 2007, 10:24 pm
a .csv file is just another text format that is easily opened in a variety of applications, for this matter it will open up in Excel no problem once the data retrieved from AutoCAD is placed into the .csv file.

chipikiri
2nd Mar 2007, 10:27 pm
Starkey, i have done the .lsp fine and loaded successfully, opened excel, tried searching from all folders still can not find the saved file, ie the extracted file.

Starkey
2nd Mar 2007, 10:29 pm
Starkey, i have done the .lsp fine and loaded successfully, opened excel, tried searching from all folders still can not find the saved file, ie the extracted file.


Gotcha, I thought you were going somewhere else with that. My fault...I guess CarlB would be the one to answer this but you might check your support folder in your AutoCAD folder.

CarlB
2nd Mar 2007, 10:36 pm
Oops, it's not easy to find, but use this typed at the command line, including parentheses <"filename" is the name you gave it including extension.:

(findfile "filename")

fuccaro
2nd Mar 2007, 10:39 pm
Try to replace the third line in the program (setq FileName...) with this one:


(setq FileName (getfiled "" "" "csv" 5))

Starkey
2nd Mar 2007, 10:41 pm
Try to replace the third line in the program (setq FileName...) with this one:


(setq FileName (getfiled "" "" "csv" 5))



what does this do, fuccaro?

CarlB
2nd Mar 2007, 10:46 pm
It opens a dialogue box for creating the file, then you can also select the folder for the file, and (I believe) it defaults to the current drawing folder, and gives it "csv" extension as a default.

chipikiri
3rd Mar 2007, 10:37 am
I am still struggling, I can not find the file output. Below is what I have tried:glare: ;

Command: ptf
Enter file name for coordinate output: fk44.cvs
Select circles to write to file:
Select objects: 1 found
Select objects: 1 found, 2 total
Select objects: 1 found, 3 total
Select objects: 1 found, 4 total
Select objects:
Command:
Command: (findfile ''fk44.cvs'')
; error: extra right paren on input
Command: (findfile fk44.cvs)
; error: bad argument type: stringp nil
Command: (findfile <fk44.cvs)
; error: bad argument type: stringp nil
Command: (findfile <''fk44.cvs'')
; error: extra right paren on input
Command: ptf
Enter file name for coordinate output: fk.xls
Select circles to write to file:
Select objects: 1 found
Select objects: 1 found, 2 total
Select objects: 1 found, 3 total
Select objects: 1 found, 4 total
Select objects:
Command:
Command: (findfile fk.xls)
; error: bad argument type: stringp nil
Command: (findfile ''fk.xls)
; error: bad argument type: stringp (QUOTE FK)



Oops, it's not easy to find, but use this typed at the command line, including parentheses <"filename" is the name you gave it including extension.:

(findfile "filename")

eldon
3rd Mar 2007, 11:23 am
I have been observing all these threads about extracting x, y coordinates, and whereas all the answers are technically brilliant, they never go quite far enough for practical on-site usage. Perhaps the problem is that the right question is not asked.

Imagine a construction site where piles are being constructed. A bulldozer has just cleaned up and taken all the setting out pegs with it. A large gentleman is jumping up and down, saying that if Pile 127 is not set out in the next few minutes, he is going to put all the crew on stand-by at £12,000 per hour. Quite a lot of pressure! So instead of scanning reams of figures, you want the information of P127 now. That is why it is so important to have an unique reference to the x,y coordinates.

If you need this unique reference, you cannot have an automatic routine to extract all coordinates, you have to do it individually, point by point. If the designer has created points that have a block with the centre coordinates and the reference as attributes, then to create the total station data file, all you have to do is extract the attributes. Otherwise you have to do it yourself, and all of the proposed solutions of extracting x,y coordinates involve some manual input to each point to sucessfully create a data file. With the increased use of total stations, it cuts down on errors to be able to go from Electronic drawing to site without manually entering data.

Incidentally, when you have a batch of points (say 300 or more), and you use Excel to sort the numbers, P2 comes after P199 and P3 comes after P299, all very logical but not very useful for data files.

dbroada
3rd Mar 2007, 02:32 pm
I'll leave aside eldon's comments as I have no idea how piles are used so I'll just look at the code....
Firstly chipikin, can you post YOUR code. You may have slipped in a quote mark or parenthesis somewhere.


Command: (findfile ''fk44.cvs'')
; error: extra right paren on input

Command: (findfile <''fk44.cvs'')
; error: extra right paren on input
I sometimes get this if LISP exits before it ends, either through an escape or a bad instruction. Lisp is still trying to evaluate an expression but its out of step. Press escape a few more times and try again.


Command: (findfile fk.xls)
; error: bad argument type: stringp nil
Command: (findfile fk44.cvs)
; error: bad argument type: stringp nil
LISP is trying to evaluate the value of a variable so you have the correct result


Command: (findfile ''fk.xls)
; error: bad argument type: stringpyou need the quote marks after .xls to close the string

when I write to files I usually start with (setq filename ("c:\\test.csv")) to make sure I know where to look. Also note the use of \\ (or /) for path references. LISP takes a single \ as a command.

fuccaro
4th Mar 2007, 08:51 am
Use the dialog box to specify the file path and place it on the desktop.

gigi7@iol.it
6th Mar 2007, 10:27 am
Hi all,
if you put on the third row

(setq filename (getfiled "Center Export File" "" "txt" 1))

all works.

Prime
16th Jan 2008, 04:37 pm
It would seem that if the 'piles' are circles or unique blocks the DATAEXTRACTION command will launch a wizard that will export those coordinates for you. And a host of other information.