2
$\begingroup$

I'm creating a an asset library using the Asset Browser features introduced in version 3.0.

How can I know for sure that an asset has already been marked without having to open the library in the Asset Browser ?

$\endgroup$

1 Answer 1

3
$\begingroup$

Using the interface

In the outliner, objects that have been marked as assets have an icon with books on the left of their name :

enter image description here

Materials and Worlds have an additional display hint in the material and world properties :

enter image description here

enter image description here

Depending on the data type you may or may not be able to mark an asset twice using the interface, but if you can you will be greeted with an error message :

enter image description here

Using Python Scripting

If an object has been marked as asset, one can access its library asset data using ID.asset_data.It has the nice added benefit of returning None if the item is not an asset.

So one can define a function to determine if an ID is an asset:

def is_asset(obj):
    return obj.asset_data is not None

Testing on a brand new file :

import bpy


def is_asset(obj):
    return obj.asset_data is not None 

obj = bpy.data.objects["Cube"]
obj.asset_mark()
print(f"Is {obj.name} an asset ? {is_asset(obj)}")
obj.asset_clear()
print(f"Is {obj.name} an asset ? {is_asset(obj)}")

Prints in the console :

Is Cube an asset ? True
Is Cube an asset ? False
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .