GhPython ExtendCurve Problem


I am currently writing a python component that extend both sides of a list of curves onto the boundary if both endpoints falls within the boundary.

The list of curves called partitions are input into x and I set it as List Access Curve Type
The boundary I set as Item Access Curve Type

The error shows is Iteration over non-sequence use of polyline curves

Any help will be much appreciated. Thanks.extendCurve Problem extendCurve (5.8 KB) extendCurve trial.3dm (23.4 KB)

Hope this help:

import Rhino.Geometry as rg
if boundry.Contains(line.To) == rg.PointContainment.Inside and boundry.Contains(line.From) == rg.PointContainment.Inside:
    curve = line.ToNurbsCurve()
    a = curve.Extend(rg.CurveEnd.Both, rg.CurveExtensionStyle.Line, [boundry]); (2.9 KB)

I tried and it works. Great thanks.

Hi Mahiyar,

I tried your few lines of code and it works perfectly for curves. However if any item in the list to be extended to the boundary is a polyline, the script gives an error when I try also to extend both ends to the boundary.

It says polyline doesn’t have the attribue ‘To’ and in the polyline class of the rhino library, I couldn’t find a way to extract it’s endpoints.

Another way I tried is to explode the all lines, if the length of the list is greater than one, meaning its a polyline, then get the first index and the last index of the exploded list of lines. However, an error msg shows ‘Guid’ object has no attribute ‘ToNurbCurves’.

Do you know anyway I can extend the two ends of the polyline to a boundary that contain it?


extendCurve trial.3dm (22.7 KB) extendCurve (11.7 KB)

import Rhino.Geometry as rg
if boundry.Contains(curve.PointAtStart) == rg.PointContainment.Inside and boundry.Contains(curve.PointAtEnd) == rg.PointContainment.Inside:
    a = curve.Extend(rg.CurveEnd.Both, rg.CurveExtensionStyle.Line, [boundry]) (3.3 KB)

Amazing thanks.