Pipe Part Data Record Error

Hello,
I made a script that will read properties from an excel spreadsheet and then write them to the part.

The problem I’m having is with the PartDataRecord. I am able to get the PartDataField’s ValueList and its items on the first run of a fresh network, change the property and then apply it to the pipe. But when I save and close everything down, then reopen the same network and run the same script, the PartDataField.ValueList returns an error:

“System.InvalidOperationException: It’s not from a fixed list. at Autodesk.Civil.DatabaseServices.PartDataField.get_ValueList()”

Am I applying the PartData the wrong way? I got the method of pipeObj.PartData = pipePartDataRecord from here.
Thank you.

Edit: I recognize I can do this through the Civil 3D Toolkits PartData nodes, I’m just trying to grow some skills via python and the API.

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
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.
cadPipe = IN[0]
errorReport = None
results = []

adoc = Application.DocumentManager.MdiActiveDocument
cdoc = CivilApplication.ActiveDocument
editor = adoc.Editor

with adoc.LockDocument():
    with adoc.Database as db:
        with db.TransactionManager.StartTransaction() as t:
            try:   
                
                pipeObj = t.GetObject(cadPipe.InternalObjectId, OpenMode.ForWrite)
                
                pipePartDataRecord = pipeObj.PartData
                pipeBedClsFld = pipePartDataRecord.GetDataFieldBy("PBC")
                
                results = pipeBedClsFld.ValueList[0]
                
                # Commented out for testing. Change pipe's Bedding Class
                #pipeBedClsFld.Value = pipeBedClsFld.ValueList[3]
                #pipeObj.PartData = pipePartDataRecord
                
            except:
                import traceback
                errorReport = traceback.format_exc()
            t.Commit()
# Assign your output to the OUT variable.
if errorReport == None:
    OUT = results
else:
    OUT = errorReport

Hi

What do you mean. “PBC”

Is there an example picture or drawing?

And try this , does it work for [ 1 ]
results = pipeBedClsFld.ValueList[1]

Hello hosneyalaa,
“PBC” is the Pipe Bedding Class part property. I retrieved it by the string method.

Here is a photo with more examples. In the bottom left are 2 pipes. The top pipe has not had its part data altered via my code. The bottom one has. Once I altered the bottom one and restarted the drawing. I can no longer access the ValueList on the bottom part. Value still works and returns what it it currently set to, but it cant seem to pull the value list. There is also the behavior that for both of them, I can still set that part property via Civil3DToolkit SetPartDataValueByName.

Check
pipeBedClsFld.IsFromList = true

Then
pipeBedClsFld.ValueList

IMG_٢٠٢٣٠٣٢٣_٢٠٠٥٤١