AutoArrange
Arranges any number of Shape3d in a roughly square pattern (X and Y), with no shapes touching each other. Primarily designed to arrange multiple independent pieces on a single build-plate.
Example usage from within a foocad/feather script :
val myShapes : Shape3d = AutoArrange().apply {
+ Cube(10)
+ Sphere( 7 ).bottomTo(0)
add( Cube( 4, 2, 2 ), 30 ) // Adds 30 copies.
}.build()
The type declaration ": Shape3d" is optional.
The pieces are placed by a heuristic, which is simple / suboptimal. It often leaves gaps which are infuriating for us humans, who can instantly see a better solution! In FooCAD's source code, see `visualTests/
You may set spacing before calling build to change the default margin (which is 1.0). If you want to increase the margin around a single shape, then use Shape3d.margin before adding it to AutoArrange.
The heuristic pays no attention to the order the shapes are added to AutoArrange.
The heuristic may change in later version of FooCAD.
Beware: the algorithm's performance is O(n²), where n is the total number of shapes. For the expected use-case, this isn't a problem.