PolylineExtensions.ObjectByGeometry outputs nothing when two lines are in-line

At output of PolyCurve to Civil 3D with PolylineExtensions.ObjectByGeometry, it outputs nothing when two lines are in-line. The code is below (I can’t upload a file). It runs well, but fails if I put Y coordinate of p2 to 0.

current = DynamoNodes.Document.Current;
layer = current.CurrentLayer;
ModelSpaceBlock = current.ModelSpace;

p1 = Point.ByCoordinates(20,0);
p2 = Point.ByCoordinates(40,1);
l1 = DesignScript.Line.ByStartPointEndPoint(Point.Origin(),p1);
l2 = DesignScript.Line.ByStartPointEndPoint(p1,p2);
pc = PolyCurve.ByJoinedCurves([l1,l2]);

PolylineExtensions.ObjectByGeometry(pc, layer, ModelSpaceBlock);

Hi @dhichisutto,

That appears to be a bug. FYI @Paolo_Emilio_Serra1.

It seems to only be an issue when all of the points are colinear. Would it suffice in your workflow to drop intermediate points that don’t change the direction of the polyline? You could group the line segments that have parallel vectors and then filter out those that share common start/end points.

Thank you for you reply @mzjensen,

Originally, successive line segments are generated from corridor feature line. It seems that I have to prepare some codes to process dropping intermediate points.

OK I see. Another option would be to use the built-in Polyline.ByPoints node instead of the Civil 3D Toolkit node.

I didn’t know Polyline.ByPoints node, and was informed in domestic forum recently. A corridor feature line is constructed with lines, and is dealt with this node.
In other case, a polyline contains arcs. Hmm…

I deal with such polyline by EXPLODing and JOINing on Civil 3D. In the case above, the result is a line, it is converted to polyline with PEDIT.