Jump to content

Lisp to import x y z coordinates to excel


Recommended Posts

Posted

Hello everyone.

I need a lisp to generate x y z values for contours from civil 3d to excel, into separate columns.

Any ideas

Thank you.

Posted

did you tried import/export tool in c3d

 

Sent from my SM-E700H using Tapatalk

Posted

You can convert CIV3D contours to plines and then could export out all the co-ordinates, the output file could be horrendous. You could export out at a spacing interval.

 

I think you need to explain more why do you need the contour co-ords ?

Posted

I am analysing a pipe network using some other software, which currently has no way of importing the contours in their current form. Hence the reason i need the contour x y z coordinates as text, preferably in excel

Posted

Yes I have. No option for exporting contour values to text

Posted (edited)

May be this one helps you (only work for 3DPOLYLINES)

 


(defun c:3dexport (/ *error* file sset pnt ssnm i vn omit )
   (defun *error* (msg)
    (if file (close file))
	(cond
	    ((not msg))
		((member msg '("Function cancelled" "quit / exit abort")))
		((princ (strcat "\nError:" msg)))
	)
	(princ)
)
(if (setq sset (ssget "_:L" '((0 . "POLYLINE"))))
    (progn
	    (if (setq file (open [color="red"](getfiled "File to Save" "C:\\" "csv" 1)[/color]  "w")) 
		    (progn
			    (write-line (strcat "Point No." "," "X" "," "Y" "," "Z") File)
			    (setq pnt 1)
				(_Layer "Point_Text" 2)
			    (repeat (setq i(sslength sset ))
				    (setq ssnm(ssname sset (setq i(1- i))))
					(setq vn (entnext ssnm))
					(while (/= "SEQEND" (cdr (assoc 0 (entget vn))))
					    (setq pts(cdr (assoc 10 (entget vn))))
						(_MakeText pts (rtos pnt 2 0) (getvar 'DIMSCALE) (Getvar 'TEXTSTYLE) "Point_Text")
						(setq omit (strcat (rtos pnt 2 0) ","(rtos (car pts) 2 4) "," (rtos (cadr pts) 2 4) "," (rtos (caddr pts) 2 4)))
						(write-line omit file)
						(setq vn(entnext vn))
						(setq pnt(1+ pnt))
					)
					
				)
				(close file)
				
			)
		
		)
	)
	(*error* "Nothing Seleted:")
)
(*error* nil)
(princ)
)
						
(defun _MakeTExt(point name ht style layer)
   (entmake (list (cons 0 "TEXT")
               (cons 10 Point)
			   (cons 1 name)
			   (cons 40 ht)
			   (cons 7 style)
			   (cons 8 layer)
		  )
)
)

(defun _layer(name col)
   (if (not (Tblsearch "LAYER" name))
    (command "_LAYER" "n" name "c" col name "")
	(command "_LAYER" "t" name "ON" name "c" col name "")
)
)

Edited by gS7
Posted

My contours are all 3d polylines. when i use the lisp it shows 372 objects found. but nothing happens next

Posted
(open (strcat "D:\\Contour_Points" ".csv") "w"))

 

Please Type Drive to save file

Posted

How do i set it up to save to the desktop

Posted

Code updated in # 6

Now you sav save file anywhere

Posted

Though it is not picking all the 3d contour polylines, i dont know why..

Posted

Please attach sample Drawing file which is not selecting contours lines

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...