Return ucs names by script

i’m trying to return all ucs names of a drawing by python, but can’t see what i’m doing wrong here.

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

ucs_list = []

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor



with adoc.LockDocument():
    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            # 
            #
            ucs_table = t.GetObject(db.UcsTableId, OpenMode.ForRead)
            for ucs_id in ucs_table:
                ucs = t.GetObject(ucs_id, OpenMode.ForRead)
                ucs_list.Append(ucs.Name)

            # Commit before end transaction
            t.Commit()
            pass

# Assign your output to the OUT variable.
OUT = ucs_list

got it working by making a custom node in c#, here is the code to learn and share.
I further wanted it to convert it to a coordinate system.

now it’s just a text input and coordinate output

        public static CoordinateSystem UCSByName(string ucsName)
        {
            // Get the current document and its database
            var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    // Get the UCS table from the database
                    UcsTable ucsTable = (UcsTable)tr.GetObject(db.UcsTableId, OpenMode.ForRead);

                    // Check if the UCS exists in the table
                    if (!ucsTable.Has(ucsName))
                    {
                        throw new ArgumentException($"UCS '{ucsName}' not found.");
                    }

                    // Get the UCS record
                    UcsTableRecord ucsRecord = (UcsTableRecord)tr.GetObject(ucsTable[ucsName], OpenMode.ForRead);

                    // Get the UCS origin and axes
                    Point3d origin = ucsRecord.Origin;
                    Vector3d xAxis = ucsRecord.XAxis;
                    Vector3d yAxis = ucsRecord.YAxis;
                    Vector3d zAxis = xAxis.CrossProduct(yAxis);

                    // Return as a Dynamo CoordinateSystem object
                    return CoordinateSystem.ByOriginVectors(pToDynamo(origin), vToDynamo(xAxis), vToDynamo(yAxis), vToDynamo(zAxis));
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException($"Error retrieving UCS '{ucsName}': {ex.Message}", ex);
                }
                finally
                {
                    tr.Commit();
                }
            }
        }

        // Extension methods to convert AutoCAD types to Dynamo types
        private static Autodesk.DesignScript.Geometry.Point pToDynamo(Point3d point)
        {
            return Autodesk.DesignScript.Geometry.Point.ByCoordinates(point.X, point.Y, point.Z);
        }

        private static Autodesk.DesignScript.Geometry.Vector vToDynamo(Vector3d vector)
        {
            return Autodesk.DesignScript.Geometry.Vector.ByCoordinates(vector.X, vector.Y, vector.Z);
        }

I like your script, thanks.
U used Append instead of append. You may want to use traceback to see what problem.

e.g.

import traceback

try:
   # do stuff
   ucs_list.append(stuff)

except:
   err = traceback.format_exc()
   ucs_list.append(err)

thanks, will tinker around with it when i have some time