> For the complete documentation index, see [llms.txt](https://dante-3.gitbook.io/dante-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dante-3.gitbook.io/dante-docs/modular-attachment-system/modular-attachment-component/common-patterns.md).

# Common Patterns

### Accessing a mesh after load completes

```cpp
// Bind to the load completed event
OpticSlot->OnAttachmentLoadCompleted.AddDynamic(this, &AMyWeapon::OnOpticLoaded);

void AMyWeapon::OnOpticLoaded(const FAttachmentEventPayload& Payload)
{
    // Safe to access — all fragments applied
    USkeletalMeshComponent* SkelMesh =
        OpticSlot->GetSkeletalMeshComponentByFragmentTag(LensTag);
    if (SkelMesh)
    {
        SkelMesh->PlayAnimation(LensOpenAnim, false);
    }
}
```

### Changing material on any mesh type

```cpp
// GetMeshComponentByFragmentTag returns UMeshComponent* — works for both
UMeshComponent* Mesh = OpticSlot->GetMeshComponentByFragmentTag(ScopeBodyTag);
if (Mesh)
{
    Mesh->SetMaterial(0, CamoMaterial);
}
```

### Checking if a slot has an attachment

```cpp
if (OpticSlot->IsAttachmentLoaded())
{
    // attachment is active
}
```

### Runtime swap

```cpp
// In Blueprint: drag SwapAttachment node, connect new definition
OpticSlot->SwapAttachment(NewScopeDefinitionSoftPtr);
```

***
