# Erorr When Run Python Script

**URL:** <https://forum.dynamobim.com/t/erorr-when-run-python-script/77768>\
**Category:** Civil 3D\
**Tags:** cpython3\
**Created:** [June 18, 2022, 7:16am UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768 "2022-06-18T07:16:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![khang.civil.2000](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@khang.civil.2000](https://forum.dynamobim.com/u/khang.civil.2000)\
**Post date:** [June 18, 2022, 7:16am UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/1 "2022-06-18T07:16:06Z")

</div>

You can fix this Erorr?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/5/c51ee50a60f273dc094bee10b8b3fb687cf573c8.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/c/dc08d29651210173839ddaf4bce40433f0892b35.png)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [June 18, 2022, 7:30am UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/2 "2022-06-18T07:30:18Z")

</div>

What is the warning ⚠ above the node say?

---

<div class="post-metadata">

**Author:** ![khang.civil.2000](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@khang.civil.2000](https://forum.dynamobim.com/u/khang.civil.2000)\
**Post date:** [June 18, 2022, 9:04am UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/3 "2022-06-18T09:04:14Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/b/fbb6b535271ff04199078866a2f52a3cda8bbb8d.png)

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [June 18, 2022, 2:04pm UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/4 "2022-06-18T14:04:24Z")

</div>

hello @khang.civil.2000 see this topic

> [@"TypeError" When Trying to Get Block Table Record of Model Space](https://forum.dynamobim.com/t/typeerror-when-trying-to-get-block-table-record-of-model-space/77729):
>
> Has anyone seen this error before? All I did was add the following code to a generic python code block: bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite) btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) And I am getting this odd “Type Error: No Method matches given arguments for OnExit: (\<class ‘Autodesk.AutoCAD.ApplicationServices.DocumentLock’\>, \<class ‘type’\>” I can use: list(bt) to see a list of blockIDs but I can’t seem to do much with them. I also get an error …

_the traceback is really blurry.  
the report of the `traceback.tb_lineno` seem missing in implementation of context manager_

---

<div class="post-metadata">

**Author:** ![khang.civil.2000](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@khang.civil.2000](https://forum.dynamobim.com/u/khang.civil.2000)\
**Post date:** [June 20, 2022, 1:36am UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/5 "2022-06-20T01:36:28Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/9/09e0888e97607d2360f1193dfe2e1a13cff555d8.png)

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

```auto
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])

```

---

<div class="post-metadata">

**Author:** ![hosneyalaa](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/hosneyalaa/32/100865_2.png) [@hosneyalaa](https://forum.dynamobim.com/u/hosneyalaa)\
**Post date:** [June 20, 2022, 2:15am UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/6 "2022-06-20T02:15:54Z")

</div>

Hi  
Using cpython 2,7

---

<div class="post-metadata">

**Author:** ![goncalogbastos](https://avatars.discourse-cdn.com/v4/letter/g/e19adc/32.png) [@goncalogbastos](https://forum.dynamobim.com/u/goncalogbastos)\
**Post date:** [June 21, 2022, 4:10pm UTC](https://forum.dynamobim.com/t/erorr-when-run-python-script/77768/7 "2022-06-21T16:10:27Z")

</div>

@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”_
