Author Topic: export coordinates from rectangles and polylines within to excel  (Read 166 times)

0 Members and 1 Guest are viewing this topic.

Juergen

  • Mosquito
  • Posts: 1
export coordinates from rectangles and polylines within to excel
« on: December 03, 2019, 05:34:07 AM »
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.

Code: [Select]
(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)
  )

roy_043

  • Water Moccasin
  • Posts: 1734
  • BricsCAD 18
Re: export coordinates from rectangles and polylines within to excel
« Reply #1 on: December 03, 2019, 10:52:17 AM »
select all rectangles within circles
Contrary to what you say it would seem the code selects all circles within rectangles. Why the triple post?

BIGAL

  • Bull Frog
  • Posts: 356
  • 30 + years of using Autocad
Re: export coordinates from rectangles and polylines within to excel
« Reply #2 on: December 03, 2019, 09:49:41 PM »
Sounds like better to do a boundary is circle or plines, then objects within, choose blocks, arcs, circle, lines, hatch etc.
Do all or pick 1 at a time.
A man who never made a mistake never made anything