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.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard

The spacing between shapes. The default value is 1.0

Functions

Link copied to clipboard
fun add(shape: Shape3d)

Add a single copy of shape

fun add(shape: Shape3d, quantity: Int)

Adds multiple copies of shape

Link copied to clipboard
fun build(): Shape3d

Call this to after adding all the shapes.

Link copied to clipboard
fun unaryPlus(shape: Shape3d)

Syntactic sugar, which allows us to do the following in feather scripts :