Strange error when trying to set surface style

I am using the civil3d document extension and when i try to set a surface style i get a strange error all of a sudden. I was on holiday for a week and I could swear before my holiday it did not throw me this error:
the package version is 1.1.32 in case that matters

Just in case someone else comes across that strange error.
As I wouldn’t get it to work no matter what I did, I just created a python node to change the surface style instead:

import sys
import clr

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

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

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
#from Autodesk.DesignScript.Geometry import *
import Autodesk.Civil.DynamoNodes as DC
import Autodesk.DesignScript.Geometry as DS

# import other references
from System.Collections.Generic import Dictionary

# The inputs to this node will be stored as a list in the IN variables.
surfaceIN = IN[0]
surfaceStyleNameIN = IN[1]

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

global adoc
global cdoc

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

        with db.TransactionManager.StartTransaction() as t:
        	for _surfID in cdoc.GetSurfaceIds():
        		obj = t.GetObject(_surfID, OpenMode.ForWrite)
        		
        		if obj.Name == surfaceIN.Name:
        			_surf = obj
        	
        	if(cdoc.Styles.SurfaceStyles.Contains(surfaceStyleNameIN)):
        		surfStyleId = cdoc.Styles.SurfaceStyles[surfaceStyleNameIN]
        		_surf.StyleId = surfStyleId
        		editor.WriteMessage("\nSurface style set to: " + surfaceStyleNameIN + "\n")
        		
        	t.Commit()
        	
OUT = "Style Changed"
1 Like