unreal.ToolsetLibrary

class unreal.ToolsetLibrary(outer: Object | None = None, name: Name | str = 'None')

Bases: BlueprintFunctionLibrary

Provides functions that are critical to Python toolset operation but which are not available in and cannot be added to any other BFPL.

C++ Source:

  • Plugin: ToolsetRegistry

  • Module: ToolsetRegistry

  • File: ToolsetLibrary.h

classmethod get_active_undo_count() int32

Returns the number of entries currently undoable on the global undo stack (queue length minus undo count, i.e. entries above the redo split).

Snapshotting this around a BeginTransaction / EndTransaction pair lets a caller tell whether the pair actually committed a record: a transient transaction (no UObject changes) is silently dropped by UTransBuffer::End, leaving the count unchanged.

Returns:

The active undo count, or 0 when there is no editor transaction buffer available (e.g. no GEditor).

Return type:

int32

classmethod get_derived_classes(base_class) Array[SoftClassPath]

Returns the list of subclasses that derive from a class. Uses the Asset Registry to find native and BP subclasses.

Parameters:

base_class (type(Class)) – The class to get subclasses from.

Returns:

The list of native and BP classes that derive from the base class.

Return type:

Array[SoftClassPath]

classmethod get_derived_structs(base_struct) Array[ScriptStruct]

Returns the list of substructs that derive from a struct. Iterates all loaded UScriptStruct objects to find matching substructs.

Parameters:

base_struct (ScriptStruct) – The struct to get substructs from.

Returns:

The list of loaded structs that derive from the base struct.

Return type:

Array[ScriptStruct]

classmethod get_object_properties(object, property_names) str

Returns the values of the requested properties.

Parameters:
  • object (Object) – The object from which to extract properties.

  • property_names (Array[Name]) – The names of the properties to extract.

Returns:

A JSON formatted string that contains the values of the requested properties.

Return type:

str

classmethod list_struct_properties(struct, user_visible_properties_only=True) str

Returns the properties of a struct as JSON Schema. By default only returns user-visible (Blueprint-accessible) properties.

WARNING: bUserVisiblePropertiesOnly=false bypasses all visibility filtering and returns every non-deprecated property on the struct. Only use this when you know that all struct properties should be exposed. For example, DataTable row structs where every field is a data column regardless of its Blueprint visibility flags.

Parameters:
  • struct (Struct) – The struct to extract properties from.

  • user_visible_properties_only (bool) – When true (default), only Blueprint-accessible properties are included. When false, all non-deprecated properties are returned.

Returns:

A JSON Schema formatted string that describes the properties.

Return type:

str

classmethod set_object_properties(object, properties_json, bypass_container_check=BypassContainerCheck.NO) bool

Sets the values of specific properties in an Object.

Partial-write semantics: writes are NOT transactional. Sibling properties whose JSON resolves cleanly are committed even when other properties (or other JSON keys within a nested struct) fail. A false return value means at least one property could not be set; it does not mean the object is unchanged. Callers that need all-or-nothing semantics should wrap the call in a transaction and roll back on failure.

Example: passing {“name”: “ok”, “doesNotExist”: 0} into a struct returns false, raises a script error naming “doesNotExist”, AND leaves “name” set to “ok”. Same applies to unknown keys inside nested structs, which surface via the same error path.

Parameters:
  • object (Object) – The object to modify.

  • properties_json (str) – The property names and values in a JSON formatted string.

  • bypass_container_check (BypassContainerCheck) – When Yes, container-size change detection is skipped and every property emits a plain ValueSet. Only use this when you know your object can handle top-level ValueSet changes instead of expecting individual ArrayAdd/ArrayRemove/ArrayClear change events when resizing containers.

Returns:

True if every property was set successfully. False indicates at least one failure; the object may already contain partial writes from sibling properties.

Return type:

bool

classmethod undo_transaction(can_redo=False) bool

Undo the most recent transaction on the global undo stack.

Companion to UKismetSystemLibrary’s BeginTransaction / EndTransaction / CancelTransaction, which cover starting and finalizing transactions but stop short of actually reverting them: CancelTransaction only discards the undo-stack entry without applying the inverse, so any modifications a partial transaction made to UObjects survive. Used by programmatic.execute_tool_script to roll back scripts that error out partway through.

Parameters:

can_redo (bool) – If true, the undone transaction stays on the redo stack. If false (default), it is removed entirely so a rolled-back script leaves no trace on the undo history.

Returns:

True if a transaction was undone; false if there was nothing to undo or the editor is in a state that prevents undo (e.g. saving a package, GC running, or no GEditor).

Return type:

bool