# Line/polyline from Sample Line?

**URL:** <https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177>\
**Category:** Civil 3D\
**Created:** [September 14, 2021, 11:23am UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177 "2021-09-14T11:23:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jameshitt](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jameshitt](https://forum.dynamobim.com/u/jameshitt)\
**Post date:** [September 14, 2021, 11:23am UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/1 "2021-09-14T11:23:40Z")

</div>

Is there a way to convert or derive a line or polyline from a C3D sample line? (Ultimately, what I’m really looking for is an intersection point between a sample line and a feature line.)

---

<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:** [September 14, 2021, 12:05pm UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/2 "2021-09-14T12:05:29Z")

</div>

see this

> [@Sample line Creation](https://forum.dynamobim.com/t/sample-line-creation/67419/13):
>
> @mzjensen Thank you for the great dynamo rely on him @abdullahcicek try this [spp3] [sampleLines\_\_Example.dyn](https://forum.dynamobim.com/uploads/short-url/swwe4Y3kUA3YekHe7cJA0LKcazY.dyn) (74.2 KB)

---

<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:** [September 14, 2021, 12:10pm UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/3 "2021-09-14T12:10:56Z")

</div>

and see

> [@Select Objects in Civil3D](https://forum.dynamobim.com/t/select-objects-in-civil3d/67008/14):
>
> Hi @1054896935, This is not going to be possible as you’ve described. The Object.Geometry node is doing a lot of work under the hood to make it possible to get the Dynamo geometric representation of many different types of native AutoCAD and Civil 3D objects. You can’t just pass anything into Object.Geometry and expect it to work because, at the moment, the Autodesk team has only implemented a limited set of object types for it to work with. So when you get the warning that says “Not implement…

---

<div class="post-metadata">

**Author:** ![jameshitt](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jameshitt](https://forum.dynamobim.com/u/jameshitt)\
**Post date:** [September 14, 2021, 12:30pm UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/4 "2021-09-14T12:30:50Z")

</div>

Thanks for directing me to that Python code. Copying it exactly into a Python code block in my dynamo script and trying it with one sample line as a selection, I get this error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.  
Traceback (most recent call last):  
File “”, line 109, in   
IndexError: index out of range: 1

(Note that in the ’ File “” ’ part, there is “string” between angle brackets, and after “in”, there is “module” between angle brackets)  
The code only goes to line 108, so what could this be referring to? @zachri.jensen

---

<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:** [September 14, 2021, 1:10pm UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/5 "2021-09-14T13:10:07Z")

</div>

hi pls  
attached dyn file +drawing file

---

<div class="post-metadata">

**Author:** ![jameshitt](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@jameshitt](https://forum.dynamobim.com/u/jameshitt)\
**Post date:** [September 14, 2021, 3:21pm UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/6 "2021-09-14T15:21:46Z")

</div>

Sure, here are the files. Its just a test/development file. In the dynamo script, the python code is in the red group. You can ignore all the rest of the scratch work in progress.  
[feature lines1.dyn](https://forum.dynamobim.com/uploads/short-url/ilQm47UcVbiko4VJeJxcBF2kToI.dyn) (113.9 KB)  
[corridors4.dwg](https://forum.dynamobim.com/uploads/short-url/5q1T1Zfc4sL0Es54j0us0zsmiCh.dwg) (746.7 KB)

---

<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:** [September 15, 2021, 3:44pm UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/7 "2021-09-15T15:44:21Z")

</div>

The reason you’re getting the index out of range error is because the node is expecting two inputs, but you’ve only provided one.

![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/b/6bf9bffca10b9e80f57fc94f0af6df00bcd340a9.jpeg)

Please see this post:

> [@Get the properties of the sample line](https://forum.dynamobim.com/t/get-the-properties-of-the-sample-line/62893):
>
> Hi Everyone! I can’t find the node for the sample line properties I need to get the properties of the sample line: name, station, coordinates …e.t.c Thanks in advance… [image]

---

<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:** [September 16, 2021, 5:48am UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/8 "2021-09-16T05:48:18Z")

</div>

![lll](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/2491e923042b4573a13581022c007fe3ea30ce11.gif)

```auto
import sys
import clr

clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

from Autodesk.AutoCAD.Colors import *

from Autodesk.Civil.DatabaseServices import *
from Autodesk.Civil import *
from Autodesk import *

def extract_basecurve(sampleLines):
	
	output=[]
	obj=[]

	if not sampleLines:
		return
	
	if not isinstance(sampleLines,list):
		sampleLines = [sampleLines]
	
	adoc = Application.DocumentManager.MdiActiveDocument
	
	with adoc.LockDocument():
		with adoc.Database as db:
			with db.TransactionManager.StartTransaction() as t:
				for SampleLine in sampleLines:
					obj = SampleLine.InternalDBObject
					vertices = obj.Vertices
					sline = Line()
					bt = t.GetObject(db.BlockTableId, OpenMode.ForRead)
					btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
					
					sline=Line(Point3d(vertices[0].Location.X,vertices[0].Location.Y,0),Point3d(vertices[2].Location.X,vertices[2].Location.Y,0))
					sline.Color = AutoCAD.Colors.Color.FromColorIndex(AutoCAD.Colors.ColorMethod.ByAci,11)
					btr.AppendEntity(sline)
					t.AddNewlyCreatedDBObject(sline, True)
					output.append(sline)
					
						
				t.Commit()			
		return output

if IN[0]:
   OUT = extract_basecurve(IN[0])
else:
     OUT = "NO DATA"

#OUT = extract_basecurve(IN[0])

```

---

<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:** [October 13, 2021, 12:27am UTC](https://forum.dynamobim.com/t/line-polyline-from-sample-line/68177/9 "2021-10-13T00:27:45Z")

</div>

@jameshitt FYI you can accomplish this with Camber as well.

 ![SampleLines](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/c/2cdbd17cc2a7a6d537b24d55fb0b69dce282a275.png)
