# For Python Developers

This plugin was developed in Unreal Engine 5.2 using a mixture of C++, Blueprints, and Python 3.9.7.&#x20;

The core logic used by the Asset Library is available in the following module:

```python
from simple_asset_library import commands
```

## Registering an Asset

To register an asset we can use the following code example:

```python
commands.register_asset(
    asset = "/Game/some/asset/path",
    asset_type = "envir",
    category = "flowers",
    display_name = "My Flower Asset"
)
```

The `asset` input can be either a **string path** to the Content Browser asset or an **unreal.Object** object

This function will take the inputs, apply them as Metadata on the asset in Unreal, and then save the asset.

## Unregistering an Asset

To unregister an asset we can use the following code example:

```python
commands.unregister_asset("/Game/some/asset/path")
```

The `asset` input can be either a **string path** to the Content Browser asset or an **unreal.Object** object

This function will remove the Metadata from the asset and then save the asset

## Get an Asset's Data

To get the Asset Library data for a registered asset, we can use:

```python
asset_data = commands.get_asset_library_data_for_asset("/Game/some/asset/path")
```

The return is a tuple with the following ordered data:

```python
(
    bool, # whether the asset is managed
    "asset type",
    "asset category",
    "asset display name"
)
```

## List the Asset Types

To get a string list of the available asset types we can use the following function:

```python
asset_types = commands.get_available_asset_types(include_all_option=False)
```

the `include_all_option` argument controls whether to include an "all" entry by default. This flag is enabled when getting the list to provide the UI

## List the Categories

To get a string list of categories for a desired asset type we can use:

```python
asset_types = commands.get_available_asset_categories(
    asset_type = "envir",
    include_all_option = False
)
```

If the `asset_type` is not provided this function will return every category found in the project for all asset types

the `include_all_option` argument controls whether to include an "all" entry by default. This flag is enabled when getting the list to provide the UI

## List the Registered Assets

To get an unreal.AssetData list of assets registered in the Asset Library we can use:

```python
assets = commands.get_asset_list(
    asset_type = "envir",
    category = "flowers"
)
```

Both arguments are optional, if an `asset_type` is provided it will only get assets of that type, and similarly if a `category` is provided it will only get assets of that category

This function returns the entries as a list of unreal.AssetData objects


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bkortbus.gitbook.io/ue5-simple-asset-library/for-python-developers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
