# Self-intersecting curves using rs.AddPlanarSrf

Hi,
I have a procedure that turns 1D lines into 2D rectangles (both in the x-y plane). Where the lines intersect the curve-boolean is used. The results are shown in the attached file.
Lines1/Boolean1 have a separation of 0.003 units compared to Lines2/Booelan2 which is 0.005 units.
The last step is to create a planar surface with the command PlanarSrf. Here is where I come across the problem. For some reason the PlanarSrf command thinks there is a self-intersecting object in Boolean1 but doesn’t have a problem in Boolean2.
Has this got anything to do with unit tolerance? Is there a way of solving this?

Thanks
Issue.3dm (64.2 KB)

Hi Hossam - on the curve that is off to the left, there is a small spur protruding from the “Lower Right”

This is where the self intersection lies - it seems not to be a real self intersection in that the gap is something like .00000002 units, but that is well within the file tolerance.

-Pascal

Hi Pascal,

You have a keen eye! I didn’t notice this at all. I can’t see why this is happening tbh. This is the script I used to create the offset:

import rhinoscriptsyntax as rs
import scriptcontext

app = 0.003

objs = scriptcontext.doc.Objects.FindByLayer(“LINES”)
rs.CurrentLayer(“Offsets”)

for obj in objs:
# offset original curve
offset_obj1 = rs.OffsetCurve(obj, [0, 0, 0], app/2)
offset_obj2 = rs.OffsetCurve(obj, [0, 0, 0], -app/2)

``````    # enclose the parallel lines
line1 = rs.AddLine(rs.CurveStartPoint(offset_obj1), rs.CurveStartPoint(offset_obj2))
line2 = rs.AddLine(rs.CurveEndPoint(offset_obj1), rs.CurveEndPoint(offset_obj2))

# Join curves
_obj = rs.JoinCurves([offset_obj1, offset_obj2, line1, line2])
rs.ObjectLayer(_obj, "Offsets")
rs.DeleteObjects([offset_obj1, offset_obj2, line1, line2])
``````

I expected this to create two strictly parallel lines but the negative offset does something funny and creates this problem. You can see this if you skip the # Join curves commands above. Is there some way of avoiding this?

I attached another .3dm file for this specific exampleIssue.3dm (36.3 KB)

Hi Hossam - the input line has a tiny segment at the end, so that when it is offset the end of the offset is folded back on the ‘main’ curve, so the end points that you are connecting are not where you expect them to be.

-Pascal