Renaming Civil 3D Corridor Assemblies


What is the correct way to rename Civil 3D Corridor Assemblies? I tried it this way and it looks like the Name property in a list of Assemblies is Read-Only. Perhaps there is a node or command to rename these? I’ve tried the ObjectExtensions.SetParameterValueByName node, however there is no Parameter for Assembly Name. Any help is appreciated! Thanks

The CivilObject.SetName node should do the trick.

2 Likes

Also, the Assembly.Name property should be writable. Are you using the correct obj class?
This one worked for me:

# 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

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

assembly = IN[0]

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

        with db.TransactionManager.StartTransaction() as t:
            # Place your code below
            assemblyid= assembly.InternalObjectId
            asseblyobj = t.GetObject(assemblyid, OpenMode.ForWrite)
            asseblyobj.Name = "Test"

            # Commit before end transaction
            t.Commit()
            pass

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

But, the solution @mzjensen suggested is more convenient.

1 Like

That did the trick, thank you.

1 Like