Erorr When Run Python Script

You can fix this Erorr?


What is the warning :warning: above the node say?

hello @khang.civil.2000 see this topic

the traceback is really blurry.
the report of the traceback.tb_lineno seem missing in implementation of context manager

1 Like

I tried but still got the error. Can you help me fix the error? Thank you

import sys
import clr


# Load the Python Standard and DesignScript Libraries
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

def get_tinvolumesurface_Vol(vs_name):
        global adoc

        vsid = None

        output = {}

        with adoc.LockDocument():
                with adoc.Database as db:
                        with db.TransactionManager.StartTransaction() as t:
                                 bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
                                 btrID = bt.get_Item("*Model_Space")
                                 btr = t.GetObject(btrID, OpenMode.ForWrite)

                                 for oid in btr:
                                        obj = t.GetObject(oid, OpenMode.ForWrite)
                                        if isinstance(obj, TinVolumeSurface):
                                                if obj.Name == vs_name:
                                                        vsid = oid
                                        if vsid is not None:
                                                break

                                 if vsid is None:
                                        return "Surface not found"

                                vs = t.GetObject(vsid, OpenMode.ForWrite)
                                props = vs.GetVolumeProperties()

                                for a in dir(props):
                                        try:
                                                output[a] = getattr(props, a)
                                        except:
                                                pass
                                t.Commit()
        return output

OUT = get_tinvolumesurface_Vol(IN[0])

Hi
Using cpython 2,7

@khang.civil.2000 it seems you have indentions wrong on code lines between “vs = t.GetObject(vsid, OpenMode.ForWrite)” and “t.commit()” and also “return output”