Renames the namespace of the specified slot reference without a dialog. Designed for pipeline automation and TA scripting — fully non-interactive. Node, layer, and SelectionSet names are all updated atomically.
Signature
api.set_namespace(slot: int, namespace: str) -> dict
Parameters
| Parameter |
Type |
Description |
slot |
int |
Slot number (0-9). Must be a plain int (bool rejected). |
namespace |
str |
New namespace name. Whitespace-only strings are rejected. |
Return Value
{"success": bool, "namespace": str, "message": str}
| Key |
Type |
Description |
success |
bool |
True on success, including no-op (same name already set). |
namespace |
str |
The namespace name now active on the slot. |
message |
str |
Human-readable status description. |
Errors
| Error |
Cause |
TypeError |
slot is not int (including bool), or namespace is not str |
ValueError |
Slot is out of range or empty, namespace is whitespace-only, or the same name already exists on another slot |
RuntimeError |
Internal namespace application failed |
Behavior Details
- No-op: If the slot already has the requested namespace, returns
{"success": True} immediately without modifying the scene.
- Duplicate check: Raises
ValueError if another occupied slot already uses the same name.
- Atomic rename: Uses the same engine as the interactive UI dialog — nodes, layers, and SelectionSets are all renamed consistently.
- Scene persistence: On success, the InfoNode UDP is saved immediately (same as all other write methods).
Example
from os_fast_ref.api import FastRefAPI
api = FastRefAPI()
# Rename slot 0 namespace to "Centaur"
result = api.set_namespace(slot=0, namespace="Centaur")
print(result["namespace"]) # "Centaur"
# Refresh the UI if it is open
api.update_ui()
Error Examples
# TypeError: slot must be int
api.set_namespace(slot="0", namespace="NewNs") # TypeError
api.set_namespace(slot=True, namespace="NewNs") # TypeError
# TypeError: namespace must be str
api.set_namespace(slot=0, namespace=123) # TypeError
# ValueError: empty namespace
api.set_namespace(slot=0, namespace=" ") # ValueError
# ValueError: "Mable" already used on another slot
api.set_namespace(slot=0, namespace="Mable") # ValueError
Pipeline Usage Example
from os_fast_ref.api import FastRefAPI
api = FastRefAPI()
refs = api.get_reference_list()
# Print current namespace list
for r in refs:
print(f"Slot {r['slot']}: {r['namespace']}")
# Rename slot 2 namespace to match pipeline naming convention
result = api.set_namespace(slot=2, namespace="Enemy_A")
if result["success"]:
print(f"Renamed to: {result['namespace']}")
api.update_ui()