Surface Analysis User Defined Contour Data Constructor - ValueError: lineTypeId

Hello everyone,

following this post I’m trying to obtain a polyline that represents the intersection between two surfaces.
However, using the SurfaceAnalysisUserDefinedContourData Constructor 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.

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

I tryed with this:

but I still get the same error:

Screenshot 2021-04-22 154455

Hi @l.florio,

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 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
3 Likes

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

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

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