# Deleting a PRC Tree

Any entity created with a Create function returns an entity handle that corresponds to some amount of memory in your system. When your work is done with this entity, you may want to release it’s associated memory by deleting it.

Deleting an entity is done differently according to whether it is already attached to another entity or not.

An entity is attached to another when is has a parent entity. For example:

- The root `A3DAsmProductOccurrence` inside an `A3DAsmModelFile` is attached to it.
- If an `A3DAsmProductOccurrence` contains a prototype, this prototype is attached to it.

Attached/Detached is simply a different way to express whether an entity is part of a PRC tree or not.

## Deleting an Attached Entity

If an entity is part of a PRC tree it _will_ be implicitly deleted upon the suppression of the model file using `A3DAsmModelFileDelete()`. Thus, you don’t have to worry about specifically deleting each entities inside a model file.

    // Delete a model file and recursively all its children:
    A3DStatus result = A3DAsmModelFileDelete(model_file);
    assert(result == A3D_SUCCESS);

All the handles of the deleted model file and its children will be invalidated.

## Deleting a Detached Entity

To delete any entity you didn’t attach to any parent, call `A3DEntityDelete()`. It will delete all the child entities as well:

    // Delete an entity and recursively all its children:
    A3DStatus result = A3DEntityDelete(entity);
    assert(result == A3D_SUCCESS);

All the handles of the deleted entity and its children will be invalidated.

Note

Some entity types require a specific function for deletion. Please see: * `A3DFileContextDelete()` * `A3DAsmModelFileDelete()` (Deprecated, use `A3DEntityDelete()`) * `A3DFaceUVPointInsideManagerDelete()` (Deprecated, use `A3DEntityDelete()`) * `A3DGraphicsDelete()` (Deprecated, use `A3DEntityDelete()`) * `A3DMiscCascadedAttributesDelete()` (Deprecated, use `A3DEntityDelete()`) * `A3DMkpRTFFieldDelete()` (Deprecated, use `A3DEntityDelete()`) * `A3DProjectPointCloudManagerDelete()` (Deprecated, use `A3DEntityDelete()`)

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Exchange in your own language, or choose a sample question below to start a conversation:

What is HOOPS Exchange?
What are the latest release notes for HOOPS Exchange?
How do I start evaluating HOOPS Exchange?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...