29 "Show assets from all of the listed asset libraries"},
34 "Show the assets currently available in this Blender session"},
39 "Show basic building blocks and utilities coming with Blender"},
44 "Show additional building blocks and utilities available online"},
49 "Show assets from the asset libraries configured in the Preferences"},
50 {0,
nullptr, 0,
nullptr,
nullptr},
55 {
ASSET_IMPORT_LINK,
"LINK", ICON_LINK_BLEND,
"Link",
"Import the assets as linked data-block"},
60 "Import the assets as copied data-block, with no link to the original asset data-block"},
64 "Append (Reuse Data)",
65 "Import the assets as copied data-block while avoiding multiple copies of nested, "
66 "typically heavy data. For example the textures of a material asset, or the mesh of an "
67 "object asset, don't have to be copied every time this asset is imported. The instances of "
68 "the asset share the data instead."},
73 "Import the asset as linked data-block, and pack it in the current file (ensures that it "
74 "remains unchanged in case the library data is modified, is not available anymore, etc.)"},
75 {0,
nullptr, 0,
nullptr,
nullptr},
83# include <fmt/format.h>
107static std::optional<std::string> rna_AssetMetaData_path(
const PointerRNA * )
112static bool rna_AssetMetaData_editable_from_owner_id(
const ID *owner_id,
116 if (owner_id && asset_data && (owner_id->asset_data == asset_data)) {
122 "Asset metadata from external libraries cannot be edited. Only assets stored in the "
123 "current file can be edited.");
132 return rna_AssetMetaData_editable_from_owner_id(ptr->owner_id, asset_data, r_info) ?
137static std::optional<std::string> rna_AssetTag_path(
const PointerRNA *ptr)
140 char asset_tag_name_esc[
sizeof(asset_tag->name) * 2];
141 BLI_str_escape(asset_tag_name_esc, asset_tag->name,
sizeof(asset_tag_name_esc));
142 return fmt::format(
"asset_data.tags[\"{}\"]", asset_tag_name_esc);
145static int rna_AssetTag_editable(
const PointerRNA *ptr,
const char **r_info)
148 ID *owner_id = ptr->owner_id;
149 if (owner_id && owner_id->asset_data) {
151 "The owner of the asset tag pointer is not the asset ID containing the tag");
155 return rna_AssetMetaData_editable_from_owner_id(
156 ptr->owner_id, owner_id ? owner_id->asset_data :
nullptr, r_info) ?
161static AssetTag *rna_AssetMetaData_tag_new(
164 const char *disabled_info =
nullptr;
165 if (!rna_AssetMetaData_editable_from_owner_id(
id, asset_data, &disabled_info)) {
172 if (skip_if_exists) {
177 reports,
RPT_WARNING,
"Tag '%s' already present for given asset",
result.tag->name);
189static void rna_AssetMetaData_tag_remove(
ID *
id,
194 const char *disabled_info =
nullptr;
195 if (!rna_AssetMetaData_editable_from_owner_id(
id, asset_data, &disabled_info)) {
207 tag_ptr->invalidate();
216static void rna_AssetMetaData_author_get(
PointerRNA *ptr,
char *value)
220 if (asset_data->author) {
221 strcpy(value, asset_data->author);
228static int rna_AssetMetaData_author_length(
PointerRNA *ptr)
231 return asset_data->
author ? strlen(asset_data->author) : 0;
234static void rna_AssetMetaData_author_set(
PointerRNA *ptr,
const char *value)
238 if (asset_data->author) {
239 MEM_delete(asset_data->author);
246 asset_data->author =
nullptr;
250static void rna_AssetMetaData_description_get(
PointerRNA *ptr,
char *value)
254 if (asset_data->description) {
255 strcpy(value, asset_data->description);
262static int rna_AssetMetaData_description_length(
PointerRNA *ptr)
265 return asset_data->
description ? strlen(asset_data->description) : 0;
268static void rna_AssetMetaData_description_set(
PointerRNA *ptr,
const char *value)
272 if (asset_data->description) {
273 MEM_delete(asset_data->description);
280 asset_data->description =
nullptr;
284static void rna_AssetMetaData_copyright_get(
PointerRNA *ptr,
char *value)
288 if (asset_data->copyright) {
289 strcpy(value, asset_data->copyright);
296static int rna_AssetMetaData_copyright_length(
PointerRNA *ptr)
299 return asset_data->
copyright ? strlen(asset_data->copyright) : 0;
302static void rna_AssetMetaData_copyright_set(
PointerRNA *ptr,
const char *value)
306 if (asset_data->copyright) {
307 MEM_delete(asset_data->copyright);
314 asset_data->copyright =
nullptr;
318static void rna_AssetMetaData_license_get(
PointerRNA *ptr,
char *value)
322 if (asset_data->license) {
323 strcpy(value, asset_data->license);
330static int rna_AssetMetaData_license_length(
PointerRNA *ptr)
333 return asset_data->
license ? strlen(asset_data->license) : 0;
336static void rna_AssetMetaData_license_set(
PointerRNA *ptr,
const char *value)
340 if (asset_data->license) {
341 MEM_delete(asset_data->license);
348 asset_data->license =
nullptr;
352static void rna_AssetMetaData_active_tag_range(
357 *
max = *softmax = std::max(
int(asset_data->tot_tags - 1), 0);
360static void rna_AssetMetaData_catalog_id_get(
PointerRNA *ptr,
char *value)
366static int rna_AssetMetaData_catalog_id_length(
PointerRNA * )
371static void rna_AssetMetaData_catalog_id_set(
PointerRNA *ptr,
const char *value)
376 if (value[0] ==
'\0') {
383 printf(
"UUID %s not formatted correctly, ignoring new value\n", value);
397 if (sfile ==
nullptr) {
404 if (asset_library ==
nullptr) {
410 asset_library->refresh_catalog_simplename(asset_data);
413static const EnumPropertyItem *rna_AssetMetaData_preferred_import_method_itemf(
422 if (
U.experimental.no_data_block_packing) {
428 if (!
U.experimental.no_data_block_packing) {
449static int rna_AssetLibrary_type_get(
PointerRNA *ptr)
455static bool rna_AssetLibrary_is_editable_get(
PointerRNA *ptr)
465 const std::optional<AssetLibraryReference> library_ref = asset_library->
library_reference();
470 &
U, library_ref->custom_library_index);
474static const char *rna_AssetLibrary_online_assets_url()
479static const char *rna_AssetLibrary_online_assets_cache_path()
484static void rna_AssetRepresentation_name_get(
PointerRNA *ptr,
char *value)
491static int rna_AssetRepresentation_name_length(
PointerRNA *ptr)
514 if (asset->is_local_id()) {
522static int rna_AssetRepresentation_id_type_get(
PointerRNA *ptr)
534static void rna_AssetRepresentation_full_library_path_get(
PointerRNA *ptr,
char *value)
538 BLI_strncpy(value, full_library_path.c_str(), full_library_path.size() + 1);
541static int rna_AssetRepresentation_full_library_path_length(
PointerRNA *ptr)
545 return full_library_path.size();
548static void rna_AssetRepresentation_full_path_get(
PointerRNA *ptr,
char *value)
551 const std::string full_path = asset->
full_path();
552 BLI_strncpy(value, full_path.c_str(), full_path.size() + 1);
555static int rna_AssetRepresentation_full_path_length(
PointerRNA *ptr)
558 const std::string full_path = asset->
full_path();
559 return full_path.size();
562static bool rna_AssetRepresentation_is_online_get(
PointerRNA *ptr)
631 "Do not add a new tag if one of the same type already exists");
667 "rna_AssetMetaData_author_get",
668 "rna_AssetMetaData_author_length",
669 "rna_AssetMetaData_author_set");
675 "rna_AssetMetaData_description_get",
676 "rna_AssetMetaData_description_length",
677 "rna_AssetMetaData_description_set");
679 prop,
"Description",
"A description of the asset to be displayed for the user");
684 "rna_AssetMetaData_copyright_get",
685 "rna_AssetMetaData_copyright_length",
686 "rna_AssetMetaData_copyright_set");
690 "Copyright notice for this asset. An empty copyright notice does not necessarily indicate "
691 "that this is copyright-free. Contact the author if any clarification is needed.");
696 "rna_AssetMetaData_license_get",
697 "rna_AssetMetaData_license_length",
698 "rna_AssetMetaData_license_set");
701 "The type of license this asset is distributed under. An empty license "
702 "name does not necessarily indicate that this is free of licensing "
703 "terms. Contact the author if any clarification is needed.");
710 "Custom tags (name tokens) for the asset, used for filtering and "
711 "general asset management");
720 "rna_AssetMetaData_catalog_id_get",
721 "rna_AssetMetaData_catalog_id_length",
722 "rna_AssetMetaData_catalog_id_set");
727 "Identifier for the asset's catalog, used by Blender to look up the "
728 "asset's catalog path. Must be a UUID according to RFC4122.");
733 "Catalog Simple Name",
734 "Simple name of the asset's catalog, for debugging and "
735 "data recovery purposes");
742 "Use Preferred Import Method",
743 "When \"Follow Asset or Preferences\" is selected for the import "
744 "method in the Asset Browser, use the preferred import method of this asset");
749 prop,
nullptr,
nullptr,
"rna_AssetMetaData_preferred_import_method_itemf");
753 "Default Import Method",
765 "Asset Representation",
766 "Information about an entity that makes it possible for the asset system "
767 "to deal with the entity as asset");
772 prop,
"rna_AssetRepresentation_name_get",
"rna_AssetRepresentation_name_length",
nullptr);
779 prop,
"rna_AssetRepresentation_owner_asset_library_get",
nullptr,
nullptr,
nullptr);
785 prop,
"rna_AssetRepresentation_metadata_get",
nullptr,
nullptr,
nullptr);
797 "The type of the data-block, if the asset represents one ('NONE' otherwise)");
803 prop,
"rna_AssetRepresentation_local_id_get",
nullptr,
nullptr,
nullptr);
806 "The local data-block this asset represents; only valid if that is a "
807 "data-block in this file");
812 "rna_AssetRepresentation_full_library_path_get",
813 "rna_AssetRepresentation_full_library_path_length",
817 prop,
"Full Library Path",
"Absolute path to the .blend file containing this asset");
822 "rna_AssetRepresentation_full_path_get",
823 "rna_AssetRepresentation_full_path_length",
829 "Absolute path to the .blend file containing this asset extended with the path "
830 "of the asset inside the file");
836 prop,
"Is Online",
"True if this asset is accessed via internet, not stored on disk");
843 srna,
"Asset Library Reference",
"Identifier to refer to the asset library");
865 "Assets and catalogs in this library can be edited from the current Blender instance");
871 prop,
"rna_AssetLibrary_user_library_get",
nullptr,
nullptr,
nullptr);
873 prop,
"User Library",
"The preferences entry defining this library, if there is one");
878 func =
RNA_def_function(srna,
"online_assets_url",
"rna_AssetLibrary_online_assets_url");
881 func,
"url",
nullptr, 0,
"URL",
"Remote location of the Online Essentials library");
885 srna,
"online_assets_cache_path",
"rna_AssetLibrary_online_assets_cache_path");
892 "Local location of the Online Essentials library's disk cache");
Main runtime representation of an asset.
#define BLT_I18NCONTEXT_ID_ID
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
eAssetLibraryType library_type() const
bool is_read_only() const
virtual std::optional< AssetLibraryReference > library_reference() const =0
std::string full_path() const
bool is_online_only() const
ID_Type get_id_type() const
std::string full_library_path() const
constexpr int64_t size() const
constexpr const char * c_str() const
StringRefNull online_essentials_cache_directory_path()
StringRefNull online_essentials_url()
const EnumPropertyItem * library_reference_to_rna_enum_itemf(bool include_readonly, bool include_current_file, bool include_remote_libraries, bool include_separate_online_essentials)
static void rna_def_asset_data(BlenderRNA *brna)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void BKE_asset_metadata_catalog_id_clear(AssetMetaData *asset_data)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
static void rna_def_asset_weak_reference(BlenderRNA *brna)
const EnumPropertyItem rna_enum_id_type_items[]
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
const EnumPropertyItem rna_enum_asset_import_method_items[]
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
void RNA_def_property_enum_default_func(PropertyRNA *prop, const char *get_default)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
PointerRNA RNA_id_pointer_create(ID *id)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void BKE_asset_metadata_catalog_id_set(AssetMetaData *asset_data, bUUID catalog_id, const char *catalog_simple_name)
struct bUserAssetLibrary * BKE_preferences_asset_library_find_index(const struct UserDef *userdef, int index) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
static void rna_def_asset_representation(BlenderRNA *brna)
const EnumPropertyItem rna_enum_asset_library_type_items[]
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
@ ASSET_LIBRARY_ESSENTIALS
@ ASSET_LIBRARY_ONLINE_ESSENTIALS
void RNA_def_asset(BlenderRNA *brna)
int rna_AssetMetaData_editable(const PointerRNA *ptr, const char **r_info)
static void rna_def_asset_tag(BlenderRNA *brna)
void RNA_define_animate_sdna(bool animate)
void BKE_asset_metadata_tag_remove(AssetMetaData *asset_data, AssetTag *tag)
AssetTag * BKE_asset_metadata_tag_add(AssetMetaData *asset_data, const char *name) ATTR_NONNULL(1
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
@ ASSET_IMPORT_APPEND_REUSE
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
PropertyRNA * rna_def_asset_library_ui_reference_common(StructRNA *srna, const char *get, const char *set)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void BKE_report(ReportList *reports, eReportType type, const char *message)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
char char size_t BLI_str_escape(char *__restrict dst, StringRef src, size_t dst_maxncpy) ATTR_NONNULL(1)
static void rna_def_asset_tags_api(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
@ ASSETDATA_USE_OWN_IMPORT_METHOD
const EnumPropertyItem rna_enum_dummy_NULL_items[]
AssetTag AssetTagEnsureResult BKE_asset_metadata_tag_ensure(AssetMetaData *asset_data, const char *name)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
static void rna_def_asset_library_reference(BlenderRNA *brna)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
bool BLI_uuid_parse_string(bUUID *uuid, const char *buffer) ATTR_NONNULL()
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_struct_flag(StructRNA *srna, StructFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BLI_uuid_format(char *buffer, bUUID uuid) ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
asset_system::AssetLibrary * ED_fileselect_active_asset_library_get(const SpaceFile *sfile)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
const EnumPropertyItem * rna_asset_library_ui_reference_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free)
SpaceFile * CTX_wm_space_file(const bContext *C)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
static void rna_def_asset_library(BlenderRNA *brna)
User defined tag. Currently only used by assets, could be used more often at some point....
Universally Unique Identifier according to RFC4122.