gom.Resource API
Summmary
The gom.Resource
API can be used to access binary data of files included in an add-on’s scripts folder.
See also
For a description of the general concept, see Using script resources.
For examples, see Examples of category script_resources
.
Class definition
- class gom.Resource
This module represents the Resource class. A utility to access resource data using relative paths and shared memory.
- static Resource.list()
Lists all resources
- Returns:
List of resources
- static Resource.cleanup()
Closing all dangling resources (API call to free memory on C++ side)
- __init__(path)
Constructor
- Parameters:
path – Qualified name of the resource
- isLoaded()
Check if the resource is loaded
- Returns:
True if the resource is loaded, False otherwise
- close()
Release resource from shared memory
- open(size=0)
Open the resource in shared memory
- exists()
Check if the resource exists
- Returns:
True if the resource exists, False otherwise
- byteSize()
Get the size of the resource in bytes
- Returns:
The size of the resource in bytes
- keepInMemory()
Keep the resource in memory
- save(size=0)
Save the resource
- Parameters:
size – Size of the resource
- Returns:
True if the save was successful, False otherwise
- saveAsUserResource(new_path, overwrite=True)
Save the resource to a new path
- Parameters:
new_path – New path to save the resource
overwrite – True to overwrite existing files, False to not overwrite