Groups and reuse#
Purpose and concepts#
group is a reusable container with local coordinates. Populate it, then place it on a page. Internal targets refer to existing instances in that group; placement replays these dependencies.
Minimal complete example#
Run this file directly with laymesh validate or laymesh render; it contains its own canvas and required definitions.
# Minimal complete example: grouppage=canvas(size=(100mm,75mm),background="#ffffff")g=group()a=g.add(rect(size=(35mm,20mm),fill="#e6f2f3"))g.add(text("Reused"),target=a.center,anchor=center)page.add(g,offset=(8mm,8mm))page.add(g,offset=(55mm,38mm),rotation=15deg)# Minimal complete example: grouppage=canvas(size=(100mm,75mm),background="#ffffff")g=group()a=g.add(rect(size=(35mm,20mm),fill="#e6f2f3"))g.add(text("Reused"),target=a.center,anchor=center)page.add(g,offset=(8mm,8mm))page.add(g,offset=(55mm,38mm),rotation=15deg)Preview
Dependencies
examples/manual/group.lay
Parameters and default behavior#
Unitless geometry uses the canvas unit; unitless type and stroke sizes use pt. Explicit call parameters override inherited/theme defaults. The linked interface reference lists accepted types, choices and defaults per parameter.
Composition#
Combine a panel, title and connector in a group, then reuse, rotate or resize it. fuse instead merges two already placed vector instances in the same container into a new outline; the inputs leave drawing and can no longer be referenced.
card = group()base = card.add(rect(size=(38 mm, 28 mm), border_radius=3 mm, fill="#d8f0ec", border_color="#087f8c", border_width=0.5 mm), target=card.top_left)card.add(ellipse(size=(10 mm, 10 mm), fill="#f2ab47"), anchor=center, target=base.center)first = page.add(card, target=page.top_left, offset=(8 mm, 30 mm))page.add(card,size=(52 mm, 38 mm), target=first.top_right, offset=(11 mm, -3 mm))# Gallery: containers / group-reusepage = canvas(name="Reusable group", size=(120 mm, 80 mm), background="#f7f9fc")font = "DejaVu Sans"heading = text(content="Reusable group", font_family=font, font_size=14 pt, color="#203864")page.add(heading, target=page.top_left, offset=(7 mm, 5 mm))# BEGIN DEMOcard = group()base = card.add(rect(size=(38 mm, 28 mm), border_radius=3 mm, fill="#d8f0ec", border_color="#087f8c", border_width=0.5 mm), target=card.top_left)card.add(ellipse(size=(10 mm, 10 mm), fill="#f2ab47"), anchor=center, target=base.center)first = page.add(card, target=page.top_left, offset=(8 mm, 30 mm))page.add(card,size=(52 mm, 38 mm), target=first.top_right, offset=(11 mm, -3 mm))# END DEMOPreview
Dependencies
examples/gallery/containers/group-reuse.lay
Common errors and limits#
First placement seals a group. It cannot contain itself, and anchors from different containers cannot be mixed directly. fuse rejects images, text and groups and is not a public general-purpose Boolean API.
Individual functions#
group#
Create a reusable container with local coordinates. Populate it before placement; first placement seals contents and reuse replays internal positioning dependencies.
Returns: material
Minimal complete source · Composition source · All parameters
fuse#
Fuse visible outlines of two placed vector instances in one container; inputs leave drawing and references. Connecting a gap requires positive bridge_width; images/text/groups are unsupported.
Returns: instance
Minimal complete source · Composition source · All parameters
Detailed behavior and further examples#
Parameters#
| Parameter | Purpose | Default or requirement |
|---|---|---|
width / height |
Group instance dimensions | Optional; scales children too |
target / offset |
Placement in the container | Use local coordinates inside a group |
Common usage#
Finish group contents before placing the group on a canvas. Groups can be reused and nested; group scaling also scales children, including text and strokes.
Limits and related topics#
Units and dimensions · Placement and anchors · Transforms and drawing order
workflow#
Complete sources and executable verification fixtures for this workflow are listed in the feature coverage map. Follow this page’s input conditions and limits when composing features.

