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.)
see this
and see
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? @mzjensen
hi pls
attached dyn file +drawing file
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 (113.9 KB)
corridors4.dwg (746.7 KB)
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.
Please see this post:
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])