Jump to content

Lisp to import x y z coordinates to excel


Alcapone001

Recommended Posts

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 ?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...