PDA

View Full Version : 2019 export coordinates from rectangles and polylines within to exfel



JSetvb
2019-11-26, 12:32 PM
Hi forum users,

i have that lsp file to select
all rectangles within circles that write the
coords from the rectangle and the
circle to an csv file.

What I need to, is an file that do
the same wiht polylines within.

See my attachment files.

Thanks for help.







(defun c:koords ( / int sel ent pts crd inc ins cir lst csv opn lwp)
;;----------------------------;;
;; Tharwat - 18.Feb.2019 ;;
;;----------------------------;;
(and (princ "\nSelct visible rectangles :")
(setq int -1 sel (ssget '((0 . "LWPOLYLINE"))))
(while (setq ent (ssname sel (setq int (1+ int))))
(setq pts nil crd nil)
(and (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (p) (= (car p) 10)) (entget ent))))
(setq inc -1 ins (ssget "_WP" pts '((0 . "CIRCLE"))))
(while (setq cir (ssname ins (setq inc (1+ inc))))
(setq crd (cons (cdr (assoc 10 (entget cir))) crd))
)
(setq lst (cons (list pts crd) lst))
)
)
;(setq csv (getfiled "Save csv file" "" "csv" 1))
(setq csv (getfiled "Save csv file" "c:/Users/jschmidthammer/Desktop/" "csv" 1))

(setq num 0 opn (open csv "w"))
(mapcar '(lambda (grp) (setq lwp t)
(mapcar '(lambda (l)
(if lwp (progn (write-line (strcat "LWpolyline (" (itoa (setq num (1+ num))) ")") opn) (setq lwp nil))
(mapcar '(lambda (str) (write-line str opn)) '("" "Circles"))
)
(mapcar '(lambda (pt)
(write-line (strcat (rtos (car pt) 2) " " (rtos (cadr pt) 2)) opn))
l
)
)
grp
)
(write-line "" opn)
)
lst
)
(close opn)
)
(princ)
)