Hi all - I wrote some code to do the following:
here is my logic:
User Selects objects to export X,Y,Z data
Loop through each entity selected - no more entities exit program
Check if entity is a line, polyline, or 3Dployline
if not continue loop
if yes extract X,Y,Z info to external file
the Code I have so far:
;; ExtXYZ_v2.LSP
;; Written by Garth Druckenmiller on March 10, 2005
;; Updated on -
;;
;; with help from various sources. Thanks to those on TheSwamp.org
(defun C:EXTXYZ ()
(Prompt "\nExtXYZ - Extracts X,Y,Z data from selected 3Dpolyline(s)")
(Prompt "\n")
(setq USEROS (getvar "osmode"))
(setvar "osmode" 0)
(setq OLD_CMDECHO (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq SELECTION_SET (ssget))
(setq NO_OF_ITEMS (sslength SELECTION_SET))
(setq SSPOSITION 0)
(repeat NO_OF_ITEMS
(setq ENTITY_NAME (ssname SELECTION_SET SSPOSITION)) ;; retrieve entity name
(setq ENTITY_LIST (entget ENTITY_NAME)) ;; retrieve info about entity
(setq ENTITY_TYPE (cdr (assoc 0 ENTITY_LIST))) ;; retrieve entity type
(cond ((equal ENTITY_TYPE "LINE")
(prompt "\n Its a LINE")
)
((equal ENTITY_TYPE "LWPOLYLINE")
(prompt "\nIts a POLYLINE")
)
;; when selected entity is a 3D polyline... do the following...
((equal ENTITY_TYPE "POLYLINE")
(prompt "\nIts a 3DPOLYLINE")
;;(setq e (entget (car (entsel))))
;get the parent entity list
(setq r 1)
;set loop control number to 1
(while r
;while loop control is not nil, carry on looping
(setq ENTITY_LIST (entget (entnext (cdr (car ENTITY_LIST)))))
;get the vertex entity list
(if (/= (cdr (assoc 0 ENTITY_LIST)) "SEQEND")
;if it is not "end-of-sequence
(progn
;do the following
(terpri)
;new line
(princ (cdr (assoc 10 ENTITY_LIST)))
;print the co-ordinates
);progn
(setq r nil)
;if end of sequence, stop looping
);if
);while
)
)
(setq SSPOSITION (1+ SSPOSITION))
)
(setvar "CMDECHO" OLD_CMDECHO)
(setvar "osmode" USEROS)
(prompt "\nProgram complete.")
(princ)
)
OK, I don't have the part where it writes to an external txt file.
It runs ok and extracts info only for 3Dpolyline for now but I'm getting a *Cancel* at end of list of vertex's. Please comment on code and if there is something really wrong. I'm very new to LISP programing so please go easy on me. Thx.