Skip to content
Development version. Forge is under active development and testing. APIs, behaviour, coverage and verification results may be incomplete or change without notice; published PASS results are not a support guarantee or production-readiness claim.

From one component to an assembly

Start with the mental model

Forge separates geometry from physical parts and from relationships between parts. Most assembly code becomes much easier once those three levels are kept separate.

You mean…Forge conceptSolidCraft result
Geometry inside one partShapeNative geometry/features in one definition
One reusable physical part@component classReusable component definition
Where/how one occurrence standsplacement=Placement(...)Occurrence placement
One placed copy of that partBlock() / copy()Component occurrence
Several parts collected togethera + bAssembly containing occurrences
One part depends on anotherattach()Native SolidCraft assembly relationship/joint
A named mounting referenceAnchor, AnchorFrame, AnchorTopologyReference used by that relationship
Browser/subassembly organisationgroup()Nested native component

1. A component means one physical part

A component is not limited to one primitive. It is the definition of one physical manufactured item. Its build() may contain several primitives, sketches, holes, bosses, fillets and other features as long as they together describe that one part.

from scpf import Box, Cylinder, component

@component
class MountingPlate:
    width = 80.0
    depth = 50.0
    thickness = 5.0

    def build(self):
        plate = Box(self.width, self.depth, self.thickness)
        boss = Cylinder(d=16, h=12).at(0, 0, self.thickness)
        return plate + boss

The plate and cylindrical boss are geometry/features inside one component. They do not need an assembly joint because they are not separate physical parts.

Physical-part test: if the boss is machined, printed or moulded as part of the plate, keep it inside one component. If it is actually a separate brass insert pressed into the plate, make a second component and relate the two occurrences in an assembly. MountingPlate is the reusable definition. Calling MountingPlate() creates one occurrence; copy() creates another occurrence of the same definition without duplicating the feature history.

2. Put components in one assembly

first = Block(placement=Placement(x=-30))
second = first.copy(placement=Placement(x=30))

assembly = first + second

Here first + second means “these two component occurrences belong to one assembly”. It does not Boolean-union their solids.

Same operator, different level:Shape + Shape describes supported geometric union; occurrence + occurrence builds an assembly of physical parts. placement=Placement(...) declares the pose when an occurrence is created or copied. It does not create a mechanical relationship; use attach() when another occurrence owns the relationship.

Exploded views are presentation, not placement

Define an exploded view after composing the final assembly. Forge stores the view in SolidCraft without changing the occurrences’ normal Placement or joints.

assembly = first + second + third
assembly = assembly.with_exploded_view("Service", scale=1.25)
assembly = assembly.with_exploded_view(
    "Instructions",
    moves=[
        (second, (0, 25, 0)),
        (third, (0, 50, 10)),
    ],
)
assembly = assembly.show_assembled()

Automatic mode uses SolidCraft’s native scale-based explosion. Explicit mode takes occurrence objects and fixed XYZ translations; Forge resolves those objects to native occurrence ids during replay. Use show_exploded("Service") to display one stored view and show_assembled() to return to normal presentation. Do not model an explosion with ordinary occurrence moves.

Technical drawings are final design presentation

SolidCraft 0.49 can keep native drawing sheets inside the saved design. In Forge, drawing intent belongs to the completed design rather than to the reusable component definition.

left = Block()
right = left.copy(placement=Placement(x=40))

assembly = left + right
assembly = assembly.with_drawing(
    left,
    name="Block drawing",
)

For a standalone part, use Block().with_drawing(name="Block drawing"). Forge asks SolidCraft to create the native A4 part sheet and standard front, top, right and isometric views, then restricts those views to the selected occurrence. The sheet explicitly documents that component. A normal build also exports the drawing as a native vector PDF below drawings/. For a more complex part, pass template="iso-a3-part".

Layout stays native: Forge does not calculate paper coordinates or projected-view placement. SolidCraft owns the template, fitted scale and standard-view layout. In this first slice a part selected from a much larger assembly can therefore use a conservative scale, because SolidCraft fits the standard group before Forge narrows the view source. Dimensions, balloons, parts lists and other drawing annotations are outside this first API slice.

3. Use @assembly when the composition itself is reusable

You do not need @assembly merely because a script contains several components. Use it when the composition itself is a reusable model object that you want to import or instantiate as a subassembly.

from scpf import Anchor, assembly

@assembly
class BlockPair:
    def build(self):
        left = Block()
        right = Block().attach(
            left,
            parent=Anchor.RIGHT,
            child=Anchor.LEFT,
        )
        return left + right

pair = BlockPair()

The component definitions remain the physical parts. BlockPair describes how those occurrences are composed. This is different from group(): an assembly expresses the model composition; grouping controls the native nested hierarchy/browser unit.

4. Use attach() when the relationship is the intent

If the real rule is “the left side of this part belongs on the right side of that part”, encode that relationship instead of calculating a replacement XYZ coordinate yourself.

from scpf import Anchor

left = Block()
right = Block().attach(
    left,
    parent=Anchor.RIGHT,
    child=Anchor.LEFT,
)

assembly = left + right

Forge records an associative attachment between the two occurrences and lowers that to the native SolidCraft relationship mechanism. The anchors say which references are related; they are not just prettier names for a hard-coded XYZ point.

This is the important rule: use an anchor when you need to describe a relationship or semantic mounting reference. Do not add anchors to every component pre-emptively.

When that relationship must rotate around one authored axis, use the same attachment references and request a native revolute joint explicitly:

moving = Leaf().attach(
    fixed,
    parent="hinge_axis",
    child="hinge_axis",
    kind="revolute",
    value=60,
    limits=(0, 180),
    name="Hinge",
)

hinge = fixed + moving

value and limits are degrees. SolidCraft owns the actual rotational degree of freedom and can drive the saved joint later; Forge does not substitute a fixed 60° occurrence rotation. Omit kind for the existing automatic rigid/planar attachment behavior.

5. Which kind of anchor?

SituationUse
Normal rectangular face/corner is enoughAnchor.LEFT, Anchor.FRONT_TOP_RIGHT, etc.
The reusable part owns a special mounting point and orientationNamed AnchorFrame returned by the component’s anchors()
The reference must follow a particular native edge/corner topologyAnchorTopology
The reference exists only because of this larger assemblyAssembly-owned with_anchor(), not an application-specific anchor added to the generic part

Start with the simplest standard Anchor. Move to AnchorFrame or AnchorTopology only when a face/corner reference cannot express the actual mounting intent.

6. Let SolidCraft own the native relationship

Forge describes the relationship; SolidCraft owns the resulting native geometry, occurrence hierarchy and joint data. Forge is not intended to grow a second general mating solver. That is also why a meaningful attach() is preferable to Forge inventing increasingly clever coordinate corrections.

offset=(u, v) moves within the attachment plane, gap is normal distance between references, and angle is the relative turn around the attachment normal. These are relationship values, not a replacement global XYZ transform.

There are two useful attachment modes. Normal attach() uses the chosen references to determine the relationship and placement. Use attach(..., as_built=True) when both occurrences are already in the intended pose and SolidCraft should record that existing pose as a fixed assembly relationship instead of repositioning them.

7. A group is organisation, not a relationship

frame = (left + right).group("Frame")

group("Frame") creates a real nested native component so the occurrences appear together in the SolidCraft browser hierarchy. Grouping does not mate, align or rotate the parts and does not replace attach().

Use a group when the collection itself is a useful named subassembly or browser unit. Do not create a group merely because two components touch.

A practical decision sequence

  1. Will these features be manufactured as one physical item? Keep them in one component, even if the geometry is complex.
  2. Is something installed or manufactured separately? Give it its own component occurrence.
  3. Do you only need a deliberate occurrence pose? Supply placement=Placement(...) when creating or copying it.
  4. Should one separate part follow another semantically? Use attach() and the simplest suitable anchor.
  5. Is a standard face/corner insufficient? Define an AnchorFrame or topology-backed reference at the level that owns that meaning.
  6. Do several occurrences form a useful named subassembly/browser unit? Then use group().

After this page, the Components and assemblies chapter covers parameter sharing, offsets, custom frames, topology anchors and assembly-owned datums in detail.