Triangular array with equal spacing between objects

Triangular array with equal spacing between objects

intern59T6U
Explorer Explorer
1,272 Views
8 Replies
Message 1 of 9

Triangular array with equal spacing between objects

intern59T6U
Explorer
Explorer

I am looking for a routine that will repeat a triangular pattern with equal distances between shapes (circles) at different angles. Array will not work, as it only gives the distance between rows and columns, NOT the distance between the objects. The pattern would then be repeated about a center point. (The square pattern below can be done with the default array command, obviously)

 

intern59T6U_0-1683115747259.png

intern59T6U_1-1683116944097.png

 

 

0 Likes
1,273 Views
8 Replies
Replies (8)
Message 3 of 9

Kent1Cooper
Consultant
Consultant

@intern59T6U wrote:

.... Array will not work, as it only gives the distance between rows and columns, NOT the distance between the objects. ....


Do you mean the clear space between objects?  If they're always Circles, that's just the column/row spacing minus the Circle diameter.  If they're sometimes other shapes, that becomes a lot more questionable depending on the angle of the Array.

 

Were you aware that an ARRAY can do the angle for you?  It doesn't appear to be something you can specify within the command, for some reason, but once drawn, you can specify it in Properties:

Kent1Cooper_0-1683122261946.png

That's not in your hexagonal arrangement, but maybe you can make use of it.

Kent Cooper, AIA
0 Likes
Message 4 of 9

intern59T6U
Explorer
Explorer

This works for my purposes. Thanks for the help!

0 Likes
Message 5 of 9

Sea-Haven
Mentor
Mentor
0 Likes
Message 6 of 9

intern59T6U
Explorer
Explorer

This one is close, but does not account for the XY spacing. It only works for the spacing between  X and Y (again, not the XY distance I am looking for. (I believe the second "copy" command  would need to be modified).

 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rectangular-array-creating-every-other-row-offset/td-p/9667120
; array rows a 1/2 x spacings
; Enter -ve values to change direction.
;By AlanH info@alanh.com.au Aug 2020

(defun c:zigzag ( / ent ss ans hor ver numx numy x )
(setq ent (entsel "\nSelect object to array"))
(setq ss (ssadd))
(ssadd (car ent) ss)
(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter spacings " "Horizontal  " 7 6 "100" "Vertical" 7 6 "50" "Num X " 5 4 "7"  "Num Y" 5 4 "7")))
(setq hor (atof (nth 0 ans)))
(setq ver (atof (nth 1 ans)))
(setq numx (atoi (nth 2 ans)))
(setq numy (atoi (nth 3 ans)))
(setq x 1.0)
(repeat (- numx 1)
(command "copy" ent "" (list 0.0 0.0) (list  (* x hor) 0.0) )
(ssadd (entlast) ss)
(setq x (+ x 1))
)
(setq x 1.0)
(while (< x numy)
(command "copy" ss "" (list 0.0 0.0) (list (* 0.5 (- hor)) (* x ver)))
(setq x (+ x 2))
)
(setq x 2.0)
(while (< x numy)
(command "copy" ss "" (list 0.0 0.0) (list 0.0 (* ver x)))
(setq x (+ x 2))
)
(princ)
)
(c:zigzag)

 

Example:

 

intern59T6U_0-1683302007158.png

 

0 Likes
Message 7 of 9

Sea-Haven
Mentor
Mentor

Its a case of Pythagoras you know the spacing is 0.781 so vertical is 0.781^2-(0.781 / 2)^2 =0.6763658403556 so can put that into my lisp. Just needs a couple of lines of code.

0 Likes
Message 8 of 9

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Its a case of Pythagoras ....


Or, it can be done trigonometrically:

 

(setq VerticalSpacing (* (sin (/ pi 3)) HorizontalSpacing))

Kent Cooper, AIA
0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

Good idea bit easier to code.

0 Likes