Skip to main content

Compound Geometries

Compound geometries create complete, closed profiles in a single call. They are ready to extrude right away.

rect

sketch("xy", () => {
rect(100, 60) // 100 wide, 60 tall, starting at current position
rect(80) // 80x80 square
rect([10, 20], 50, 30) // 50x30 rectangle starting at position [10, 20]
})

Useful methods on rect:

import { sketch } from 'fluidcad/core';
import { rect } from 'fluidcad/core';

sketch("xy", () => {
rect(100, 60).center().radius(5)
})

Rounded centered rectangle

You can also access individual edges of a rect:

const r = rect(100, 60)
r.topEdge() // the top edge
r.bottomEdge() // the bottom edge
r.leftEdge() // the left edge
r.rightEdge() // the right edge

polygon

import { sketch } from 'fluidcad/core';
import { polygon } from 'fluidcad/core';

sketch("xy", () => {
polygon(6, 80)
})

Hexagon

slot

An obround shape (rectangle with rounded ends):

import { sketch } from 'fluidcad/core';
import { slot } from 'fluidcad/core';

sketch("xy", () => {
slot(100, 30)
})

Slot shape

Slot from edge

You can create a slot that follows an existing edge or arc. Pass the geometry as the first argument and the width as the second:

import { sketch } from 'fluidcad/core';
import { move, arc, slot } from 'fluidcad/core';

sketch("xy", () => {
move([100, 0])
const a = arc(90, 0, 90)
slot(a, 20, true)
})

Slot from edge

The third argument (true) removes the source geometry after creating the slot. Set it to false to keep the original edge.