Documentextensions.SetStyle not working

Documentextensions.setstyle keeps throwing errors when I try to set the surface style as shown here:

Any idea why it does not work?

Can you check the outputs from the nodes upstream? They might return null as well.

Seems to be getting the surfaces in previous nodes,

What does the yellow errormessage say?

Warning: DocumentExtensions.SetStyle operation failed.
Could not load type ‘Autodesk.Civil.DatabaseServices.PressureAppurtenanceSectionLabel’ from assembly ‘AeccPressurePipesMgd, Version=13.3.854.0, Culture=neutral, PublicKeyToken=null’.

Not sure why but try to check the Style name and the last node.

The last node returned null after the first run because the surfaces didn’t had the style anymore that I Listed indices for on in the middle of the graph

I ended up modifying some python code to do the style change and seems to work. 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]
surfaceIN2 = IN[2]
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
            elif obj.Name == surfaceIN2.Name:
                _surf2 = obj
            
        if cdoc.Styles.SurfaceStyles.Contains(surfaceStyleNameIN):
            surfStyleId = cdoc.Styles.SurfaceStyles[surfaceStyleNameIN]
            _surf.StyleId = surfStyleId
            _surf2.StyleId = surfStyleId
            editor.WriteMessage("\nSurface style set to: " + surfaceStyleNameIN + "\n")
            
        t.Commit()

OUT = “Style Changed”