# Surface Analysis User Defined Contour Data Constructor - ValueError: lineTypeId

**URL:** <https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163>\
**Category:** Civil 3D\
**Tags:** python, api, civil3d\
**Created:** [April 22, 2021, 8:12am UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163 "2021-04-22T08:12:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![l.florio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/l.florio/32/111603_2.png) [@l.florio](https://forum.dynamobim.com/u/l.florio)\
**Post date:** [April 22, 2021, 8:12am UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/1 "2021-04-22T08:12:06Z")

</div>

Hello everyone,

following this [post](https://forums.autodesk.com/t5/civil-3d-customization/api-minimumdistbetweensurfaces/td-p/8368711) I’m trying to obtain a polyline that represents the intersection between two surfaces.  
However, using the [SurfaceAnalysisUserDefinedContourData Constructor](http://docs.autodesk.com/CIV3D/2016/ENU/API_Reference_Guide/html/f4849b9b-4976-31fe-e742-0c75080f61b0.htm) I’m getting a ValueError: lineTypeId.

```
import clr
from System import Array

# Add Assemblies for AutoCAD and Civil3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# 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 *
from Autodesk.AutoCAD.Colors import *
from Autodesk.AutoCAD.Windows import *

# Import references for PropertySets
from Autodesk.Aec.PropertyData import *
from Autodesk.Aec.PropertyData.DatabaseServices import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor

surface = IN[0]

surfaceId = None

with adoc.LockDocument():
	with adoc.Database as db:
		with db.TransactionManager.StartTransaction() as t:
			bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
			btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
			
			ltd = LinetypeDialog()
			dr = ltd.ShowDialog()
			ltId = ltd.Linetype

			for oid in btr:
				obj = t.GetObject(oid, OpenMode.ForRead)
				if isinstance(obj, TinVolumeSurface):
					if obj.Name == surface.Name:
						surfaceId = oid
									
				if surfaceId is not None:
					break

			vs = t.GetObject(surfaceId, OpenMode.ForRead)
			
			gp = vs.GetGeneralProperties()
			minel = gp.MinimumElevation
			
			vs.Analysis.SetUserDefinedContourData(Array[SurfaceAnalysisUserDefinedContourData(0, Color.FromRgb(255, 0, 0), ltId, LineWeight.ByLayer)])
			
			t.Commit()

OUT = ltId

```

I can’t understand where the problem is, because this is the first time I’m trying to obtain something with Civil 3D API.

Thanks for your help.

---

<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:** [April 22, 2021, 10:54am UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/2 "2021-04-22T10:54:31Z")

</div>

Looks like you may be getting the Linetype and not LinetypeId?

[https://help.autodesk.com/cloudhelp/2021/ENU/Civil3D-API/files/html/3acad3f0-a842-e614-a10f-b488671a1704.htm](https://help.autodesk.com/cloudhelp/2021/ENU/Civil3D-API/files/html/3acad3f0-a842-e614-a10f-b488671a1704.htm)

---

<div class="post-metadata">

**Author:** ![l.florio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/l.florio/32/111603_2.png) [@l.florio](https://forum.dynamobim.com/u/l.florio)\
**Post date:** [April 22, 2021, 1:54pm UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/3 "2021-04-22T13:54:34Z")

</div>

I tryed with this:

 ![Screenshot 2021-04-22 154147](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/c/3c8a746745ed4681db5424d666d62a2dbcb663cf.jpeg)

but I still get the same error:

![Screenshot 2021-04-22 154455](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/f/7fe22d822f0a3c20ff3dd768796c8ff84d227cca.jpeg)

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [April 25, 2021, 7:30pm UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/5 "2021-04-25T19:30:36Z")

</div>

Hi @l.florio,

> [@l.florio](#):
>
> I’m trying to obtain a polyline that represents the intersection between two surfaces.

Sorry to depart from the lineTypeId question, but I’m thinking ahead and wondering if the _SurfaceAnalysisUserDefinedContourData_ class is going to get you to your ultimate goal of getting a polyline. I don’t think that class has the methods you’d need to create a polyline. Maybe [this approach](https://forums.autodesk.com/t5/civil-3d-customization/intersection-lines-between-two-surfaces/m-p/4522349#M7962) would work?

1. Create a temporary TIN surface
2. Paste the volume surface into the temporary TIN surface
3. Use the _ExtractContoursAt_ method with an elevation of 0
4. Dispose of the temporary TIN surface

---

<div class="post-metadata">

**Author:** ![l.florio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/l.florio/32/111603_2.png) [@l.florio](https://forum.dynamobim.com/u/l.florio)\
**Post date:** [April 26, 2021, 8:51am UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/6 "2021-04-26T08:51:01Z")

</div>

Thank you @zachri.jensen for your suggestion, it works and it is a much easier approach.

---

<div class="post-metadata">

**Author:** ![KirkWM](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kirkwm/32/104406_2.png) [@KirkWM](https://forum.dynamobim.com/u/KirkWM)\
**Post date:** [April 26, 2021, 4:21pm UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/7 "2021-04-26T16:21:49Z")

</div>

You can also try the longest Civil 3D command ever, MINIMUMDISTANCEBETWEENSURFACES

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/8/588d3f473d61e4817cba4f7a5b6170392b2ea776.png)

---

<div class="post-metadata">

**Author:** ![l.florio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/l.florio/32/111603_2.png) [@l.florio](https://forum.dynamobim.com/u/l.florio)\
**Post date:** [April 27, 2021, 6:55am UTC](https://forum.dynamobim.com/t/surface-analysis-user-defined-contour-data-constructor-valueerror-linetypeid/63163/8 "2021-04-27T06:55:44Z")

</div>

Thank you @KirkWM but I’m trying to automate the workflow with Dynamo and MINIMUMDISTBETWEENSURFACES comand is not implemented in Civil 3D API.
