Assets: Add full_path attribute to AssetRepresentation

The current documentation on `AssetRepresentation.full_library_path` indicates
that it will give the fully qualified path to the asset (the path to the
`.blend` file extended with the path to the asset).

This is not the case however, and it only returns the path to the `.blend`
file, leaving there no way to actually get an easy-to-use path to the asset.

This commit adds a new `full_path` property to `AssetRepresentation` that lets
the user get the fully qualified path to the asset. The documentation for the
`full_library_path` has been updated to accurately reflect what it does.
This commit is contained in:
Colin Basnett
2023-09-25 14:53:41 +02:00
committed by Julian Eisel
parent eab95fa2aa
commit 166f7c7a98

View File

@@ -425,6 +425,20 @@ static int rna_AssetRepresentation_full_library_path_length(PointerRNA *ptr)
return full_library_path.size();
}
static void rna_AssetRepresentation_full_path_get(PointerRNA* ptr, char* value)
{
const AssetRepresentation* asset = static_cast<const AssetRepresentation*>(ptr->data);
const std::string full_path = asset->get_identifier().full_path();
BLI_strncpy(value, full_path.c_str(), full_path.size() + 1);
}
static int rna_AssetRepresentation_full_path_length(PointerRNA* ptr)
{
const AssetRepresentation* asset = static_cast<const AssetRepresentation*>(ptr->data);
const std::string full_path = asset->get_identifier().full_path();
return full_path.size();
}
const EnumPropertyItem *rna_asset_library_reference_itemf(bContext * /*C*/,
PointerRNA * /*ptr*/,
PropertyRNA * /*prop*/,
@@ -651,9 +665,22 @@ static void rna_def_asset_representation(BlenderRNA *brna)
"rna_AssetRepresentation_full_library_path_get",
"rna_AssetRepresentation_full_library_path_length",
nullptr);
RNA_def_property_ui_text(
prop,
"Full Library Path",
"Absolute path to the .blend file containing this asset");
prop = RNA_def_property(srna, "full_path", PROP_STRING, PROP_FILENAME);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop,
"rna_AssetRepresentation_full_path_get",
"rna_AssetRepresentation_full_path_length",
nullptr);
RNA_def_property_ui_text(
prop,
"Full Library Path",
"Full Path",
"Absolute path to the .blend file containing this asset extended with the path "
"of the asset inside the file");
}