Create arrays
I wish to create an array of points, these arrays of points should be extracted from the rectangle's divided in section's middle point, variable N sections (columns and rows) like a grid, then store it in a list or array object.
In the image, I need to save the store point represented by the points.
Any help?
Comments
-
So you just want the circle points or the line points as well, pretty easy you are talking 1/4 & 1/2 dist along the rectang shape.
So this will get the 4 corner points then just use divide method, to work out the other points.
(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))A big question will the rectangs be rotated ? As there is 2 ways to work out the new points. Polar & mapcar +
1 -
Bonjour @jtm2020hyo
I am not sure to understand as well.
You select the rectangle polyline, your type the number of rows and columns.
Then the program must calculate all intersection points and centers of "boxes".
Does the program draw all lines and circles ?Thank you for helping me understand so I can help you
Amicalement
1 -
I wish to store all intersections to mapcar (circles in the image). The lines and rectangles are references
0 -
Something like this, result is in lst.
; https://forum.bricsys.com/discussion/39392/create-arrays#latest
; By Alan H Dec 2024
(defun c:circrect ( / co-ord col colspac ent lst rad row rowspac x y)
(setq ent (car (entsel "\nPick rectang ")))
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent))))
(setq row (getint "\nHow many rows "))
(setq col (getint "\nHow many columns "))
(setq rad (getreal "\nEnter radius of circle "))
(setq co-ord (vl-sort co-ord
'(lambda (a b)
(cond
((< (car a) (car b)))
((= (car a) (car b))
(< (cadr a) (cadr b)))
)
)
)
)
(setq xdist (- (car (last co-ord))(car (car co-ord))))
(setq ydist (- (cadr (last co-ord))(cadr (car co-ord))))
(setq pt (car co-ord))
(setq rowspac (/ ydist (+ 1.0 row)))
(setq colspac (/ xdist (+ 1.0 col)))
(setq x 1.0 y 1.0 lst'())
(repeat col
(repeat row
(setq npt (mapcar '+ pt (list (* X colspac) (* Y rowspac) 0.0)))
(command "circle" npt rad)
(setq y (1+ y))
(setq lst (cons npt lst))
)
(setq x (1+ x) y 1)
)
(princ)
)1