TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Juergen 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.
(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)
)
-
select all rectangles within circles
Contrary to what you say it would seem the code selects all circles within rectangles. Why the triple post?
-
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.
-
Hi, roy_043!
It's right, the code selects all circles within rectangles,
but what I mean is that I can select all rectangles not
one by one.
The triple post comes because there are always errors
at the uploading.
Did you check my attached files?
Here it is clear what I mean exactly.
Thanks for help.
-
Sorry, but you have caught me at the wrong time. I am more and more reluctant to help people who have zero interest in learning how to write Lisp code themselves.
Source of the original code:
https://www.cadtutor.net/forum/topic/66838-coordinates-from-rectangles-and-circles-inside