Circle and Sphere Packing
I’ve yet to figure out how to go about turning my main Charge field atomic modeling project into a molecule maker, then into an Addon. In the meantime, here’s some proof of life, a quick and easy Blender project, with AI help of course. Circle and sphere Packing. Still, it took me a few hours to request and understand it, make notes and changes, then find and correct a bad initial y_offset value suggested in the sphere packing section. 1. A 2d hexagonal close packed array of overlapping circles, 7 circles; 2. A grid of circles with variable rows and columns; 3. 3d hexagonal close packed spheres consisting of two alternating layers. First un-comment (remove) the pair of triple ( ''' ) quotes at the top and bottom of the section you wish to mess with. Here’s the AI instructions for creating the Blender python SG grid. AI wrote. QUOTE How to use the script Open the Scripting Workspace: Open Blender and switch to the Scripting workspace via the tabs at the top. Create a New Script: In the text editor window, click the New button. Paste the Code: Copy the code above and paste it into the editor. Adjust Settings (Optional): Change the variables at the top of the script (circles_across, rows_down, circle_radius, overlap_factor) to get your desired grid. Run the Script: Click the Run Script button (the "play" icon) in the text editor header. How it works Variable Control: The top section provides a clear way to control the grid's dimensions and overlap. Clear Scene: The script first deletes any old circles from previous runs to ensure a clean slate. This is a best practice for re-running scripts. Hexagonal Spacing: The core of the hexagonal grid is in the x_spacing and y_spacing calculations. A hexagon's geometry dictates that the vertical distance between row centers is a multiple of $\sqrt{3}/2$. Row Offset: A hexagonal pattern requires every other row to be horizontally shifted. The if row % 2 == 1: statement handles this by adding x_offset to odd-numbered rows.