Updating propertySetInformation

Hi Guys. Its my first time using Dynamo and I am having some issues in updating propertyset information. I am trying to update the PropertySet “COBie.Space” property “COBie.Space.Name” for selected objects. The value should start at 1 and increment by 1 for each object selected. I have attached my select objects node to a python script with the following code:

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

import Autodesk.AutoCAD.Runtime as Runtime
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 *

Get the selected objects

selection = IN[0]

Initialize the counter

counter = 1

Start a transaction

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

db = adoc.Database

transaction = db.TransactionManager.StartTransaction()
try:
# Loop through the selected objects
for obj in selection:
obj = transaction.GetObject(obj.ObjectId, OpenMode.ForWrite)
# Check if the object has the “COBie.Space” property set
if obj.PropertySets.Contains(“COBie.Space”):
# Get the “COBie.Space” property set
propSet = obj.PropertySets.GetPropertySet(“COBie.Space”)
# Update the “COBie.Space.Name” property
propSet.Set(“COBie.Space.Name”, str(counter))
counter += 1
transaction.Commit()
except Exception as e:
print(e)
finally:
transaction.Dispose()

No matter how I try to relook at this code (I am no python expert) I cannot get this functionallity to work. Any assistance would be greatly appreciated

HI @Dylan.TaylorZ6WK2
I HAVE ERORR
Can you attached DYN FILE