block()

SCAD base module for creating STL models of standard and custom LEGO® compatible bricks and plates optimized for 3D printing.

grid

A List of two values [x, y] that define the dimensions of the brick as a multiple of gridSizeXY in the X and Y directions.

Type
List
Default
[1, 1]

gridSizeXY

The grid size along the X-axis and Y-axis in mm. By default, this correspondents to the side length of a 1x1 LEGO brick.

Type
Number
Default
8.0

gridSizeZ

The grid size along the Z-axis in mm.

Type
Number
Default
3.2

gridOffset

The X, Y and Z offset of the brick compared to its original position. The X and Y values are specified as multiples of gridSizeXY, the Z value as a multiple of gridSizeZ.

Type
List
Default
[0, 0, 0]

baseHeight

The base height of the brick. By default, this value corresponds to the height of a LEGO plate without the height of the knobs. Multiplying by baseLayers gives the total height of the brick.

Type
Number
Default
3.2

baseLayers

Number of layers of the brick. Multiplied by baseHeight gives the total height of the brick.

Type
Number
Default
1

baseCutoutType

The type of the cutout on the bottom of the brick. Valid values are 'none', 'classic', 'groove'

Type
String
Default
classic

baseCutoutMinDepth

The minimum depth of the base cutout.

Type
Number
Default
2.4

baseCutoutMaxDepth

The maximum depth of the base cutout.

Type
Number
Default
9.0

baseClampHeight

The height of the clamp skirt in the base cutout.

Type
Number
Default
0.8

baseClampThickness

The horizontal thickness of the clamp skirt in the base cutout.

Type
Number
Default
0.1

baseClampOffset

The offset of the base clamp.

Type
Number
Default
0.4

baseRoundingRadius

The rounding radius of the edges, specified either as a single value for all axes, or as a list with 3 values for each axis, which again can be a single value for all corners of the axis, or as list with 4 values for each corner of each axis.

Type
Number | List
Default
0.0

baseCutoutRoundingRadius

The rounding radius of the base cutout, specified either as single value for all corners, or as list with 4 values for each corner.

Type
Number
Default
0.0

baseRoundingResolution

The resolution for base roundings.

Type
Number
Default
30

baseSideAdjustment

A List with four values in mm [x1, x2, y1, y2] to be subtracted from or added to each side of the brick after the dimensions have been calculated. If a single value x is specified, this corresponds to a List [x, x, x, x]. If a List [x, y] is specified, this corresponds to a List [x, x, y, y].

Type
Number | List
Default
-0.1

baseHeightAdjustment

A value in mm to add to or subtract from the final calculated base height.

Type
Number
Default
0.0

wallThickness

The wall thickness of the block within the base cutout.

Type
Number
Default
1.5

wallGapsX

Type
List
Default
[]

wallGapsY

Type
List
Default
[]

topPlateHeight

The preferred height of the top plate of the block.

Type
Number
Default
0.8

topPlateHelpers

Whether to draw a thin line along the walls before drawing the top plate for better adhesion.

Type
Boolean
Default
true

topPlateHelperOffset

The offset of the lines drawn along the y-axes.

Type
Number
Default
0.2

topPlateHelperHeight

The vertical height of the plate helper.

Type
Number
Default
0.2

topPlateHelperThickness

The horizontal thickness of the plate helper.

Type
Number
Default
0.4

slanting

Whether the block should be slanted. Could be either false or a List of Multiples of gridSizeXY to specify the slanting for each side. Positive values will result in a slanting on the top, negative on the bottom.

Type
Boolean | List
Default
false

slantingLowerHeight

The height of the part that will not be slanted.

Type
Number
Default
2

stabilizerGrid

Whether to draw lines to connect the pillars to the walls before drawing the top plate for better brick stability.

Type
Boolean
Default
true

stabilizerGridOffset

The offset of the pillar helper lines drawn along the Y-axes

Type
Number
Default
0.2

stabilizerGridHeight

The vertical height of the pillar helper lines.

Type
Number
Default
0.8

stabilizerGridThickness

The horizontal thickness of the pillar helper lines.

Type
Number
Default
0.8

stabilizerExpansion

if greater zero, the each nth stabilizer is expanded to maximum size.

Type
Number
Default
2

stabilizerExpansionOffset

The distance between expanded stabilizers to the bottom of the brick.

Type
Number
Default
1.8

pillars

Whether the brick should have pillar tubes / pins within the base cutout. Can be a list to specify which pillars are drawn or omitted respectively. If set to 'auto' the pillar gaps will be calculated.

Type
Boolean | List | String
Default
true

pillarRoundingResolution

The resolution for pillar roundings.

Type
Number
Default
30

pillarGapCornerLength

Type
Number
Default
2

pillarGapMiddle

Type
Number
Default
10

pinSize

The diameter of the tube pin in 1 x n and n x 1 bricks.

Type
Number
Default
3.2

pinClampThickness

The thickness of the clamp on the pin.

Type
Number
Default
0.1

pinClampOffset

The offset of the clamp on the pin.

Type
Number
Default
0.4

tubeXSize

The outer diameter of holes on the X-axis.

Type
Number
Default
6.4

tubeYSize

The outer diameter of holes on the Y-Axis.

Type
Number
Default
6.4

tubeZSize

The outer diameter of pillar tubes.

Type
Number
Default
6.4

tubeInnerClampThickness

The thickness of the inner clamp on the pillar tubes.

Type
Number
Default
0.1

tubeOuterClampThickness

The thickness of the outer clamp on the pillar tubes.

Type
Number
Default
0.1

tubeOuterClampOffset

The offset of the outer clamp on the tube.

Type
Number
Default
0.4

tubeOuterClampHeight

The height of the outer clamp on the tube.

Type
Number
Default
0.8

holesX

Whether the brick should have LEGO Technic holes along the X-Axis.

Type
Boolean
Default
false

holeXSize

The inner diameter of X holes

Type
Number
Default
5.1

holeXInsetThickness

The thickness of the inset of X holes.

Type
Number
Default
0.6

holeXInsetDepth

The depth of the inset of X holes.

Type
Number
Default
0.9

holeXGridOffset

Multiple of gridSizeZ to specify the offset of the X holes from bottom.

Type
Number
Default
1.75

holeXGridSizeZ

Multiple of gridSizeZ to specify the size of the X hole grid.

Type
Number
Default
3

holeXGridSizeZ

Multiple of gridSizeZ to specify the size of the X hole grid.

Type
Number
Default
3

holeXMinTopMargin

The minimum margin between the last X hole and the top of the block.

Type
Number
Default
0.8

holesY

Whether the brick should have LEGO Technic holes along the Y-Axis.

Type
Boolean
Default
false

holeYSize

The inner diameter of Y holes

Type
Number
Default
5.1

holeYInsetThickness

The thickness of the inset of Y holes.

Type
Number
Default
0.6

holeYInsetDepth

The depth of the inset of Y holes.

Type
Number
Default
0.9

holeYGridOffset

Multiple of gridSizeZ to specify the offset of the Y holes from bottom.

Type
Number
Default
1.75

holeYGridSizeZ

Multiple of gridSizeZ to specify the size of the Y hole grid.

Type
Number
Default
3

holeYGridSizeZ

Multiple of gridSizeZ to specify the size of the Y hole grid.

Type
Number
Default
3

holeYMinTopMargin

The minimum margin between the last Y hole and the top of the block.

Type
Number
Default
0.8

holesZ

Whether the brick should have LEGO Technic holes between the knobs.

Type
Boolean
Default
false

holeZSize

The inner diameter of Z holes.

Type
Number
Default
5.1

holeRoundingResolution

The rounding resolution for all holes (x, y, z) and pillars (tubes, pins)

Type
Number
Default
30

knobs

Whether the block should have knobs.

Type
Boolean
Default
true

knobType

The type of the knobs. Valid values are 'none', 'classic', "technic"

Type
String
Default
classic

knobCentered

Whether the knobs should be centered on the brick.

Type
Boolean
Default
false

knobSize

The diameter of the knobs.

Type
Number
Default
5.0

knobHeight

The height of the knobs.

Type
Number
Default
1.8

knobClampHeight

The height of the knob clamp.

Type
Number
Default
0.8

knobClampThickness

The thickness of the knob clamp.

Type
Number
Default
0.0

knobHoleSize

The diameter of the inner knob holes if the knobs are not filled.

Type
Number
Default
3.5

knobHoleClampThickness

The thickness of the clamp inside the knob holes.

Type
Number
Default
0.1

knobRounding

The knob rounding.

Type
Number
Default
0.1

knobRoundingResolution

The rounding resolution of the knobs.

Type
Number
Default
30

tongue

Whether the block should have a tongue.

Type
Boolean
Default
false

tongueHeight

The height of the tongue.

Type
Number
Default
2.0

tongueKnobSize

Knob size to be used to calculate the position of the tongue to maintain compatibility with other blocks.

Type
Number
Default
5.0

tongueRoundingRadius

Rounding radius of the tongue.

Type
Number
Default
0.0

tongueThickness

The thickness of the tongue.

Type
Number
Default
1.1

tongueOuterAdjustment

The outer adjustment of the tongue.

Type
Number
Default
0.0

tongueClampHeight

The height of the clamp on the tongue.

Type
Number
Default
0.8

tongueClampOffset

The offset of the clamp on the tongue.

Type
Number
Default
0.4

tongueClampThickness

The thickness of the clamp on the tongue.

Type
Number
Default
0.1

tongueGrooveDepth

The depth of the groove for the tongue.

Type
Number
Default
2.4

pit

Whether the brick has a pit.

Type
Boolean
Default
false

pitRoundingRadius

Rounding radius of the pit.

Type
Number
Default
0.0

pitDepth

The depth of the pit. If set to zero, the depth is calculated automatically.

Type
Number
Default
0.0

pitWallThickness

The wall thickness of the pit as multiplier of gridSizeXY.

Type
Number
Default
0.333

pitWallGaps

A list of gaps in the pit walls.

Type
List
Default
[]

text

The text to draw.

Type
String
Default

textSide

Type
Number
Default
1

textDepth

Type
Number
Default
0.6

textFont

The font family name.

Type
String
Default
Helvetica Bold

textSize

The font size.

Type
Number
Default
4

textSpacing

Type
Number
Default
1

textHorizontalAlign

Type
String
Default
center

textVerticalAlign

Type
String
Default
center

textOffset

A List with horizontal and vertical text offset as multipliers of gridSizeXY and gridSizeZ depending on the side.

Type
List
Default
[0, 0]

svg

The svg to draw.

Type
String
Default

svgSide

Type
Number
Default
5

svgDepth

Type
Number
Default
0.6

svgScale

The scale of svg.

Type
Number
Default
1

svgOffset

A List with horizontal and vertical svg offset as multipliers of gridSizeXY and gridSizeZ depending on the side.

Type
List
Default
[0,0]

screwHolesZ

Type
List
Default
[]

screwHoleZSize

Type
Number
Default
2.3

screwHoleZHelperThickness

Type
Number
Default
0.8

screwHoleZHelperOffset

Type
Number
Default
0.2

screwHoleZHelperHeight

Type
Number
Default
0.2

screwHolesX

Type
List
Default
[]

screwHoleXSize

Type
Number
Default
2.1

screwHoleXDepth

Type
Number
Default
4

screwHolesY

Type
List
Default
[]

screwHoleYSize

Type
Number
Default
2.1

screwHoleYDepth

Type
Number
Default
4

center

If true, the brick is centered in OpenSCAD.

Type
Boolean
Default
true

alignBottom

If true, the stone is always placed on the floor in OpenSCAD, even if center is set to true.

Type
Boolean
Default
true

alignIgnoreAdjustment

If true, baseSideAdjustment is not taken into account when positioning the brick in OpenSCAD. This is useful if you want to align multiple bricks with brickOffset so that you can use baseSideAdjustment to fill gaps.

Type
Boolean
Default
true

adhesionHelpers

Whether to draw lines to connect the pillars to the walls on the first layer for better bed adhesion.

Type
Boolean
Default
false

adhesionHelperHeight

The vertical height of the adhesion helper lines.

Type
Number
Default
0.2

adhesionHelperThickness

The horizontal thickness of the adhesion helper lines.

Type
Number
Default
0.4

previewQuality

Number between 0.0 and 1.0 to specify the preview rendering quality compared to final quality.

Type
Number
Default
1.0
LEGO is a registered trademark of the LEGO Group. MachineBlocks is not affiliated with or sponsored by the LEGO Group.