I asked ChatGPT to OffsetExtendCrv on Srf in Gh

The component offsets a number of curves at a specified distance on a surface and extends them up till surface boundary. This is done recursively, each curve is created based on the previous one. This is very advantageous when solving corner details.

In this example i use another custom component that creates a network surface based on 2 input curves.

OffsetExtendRecu:

import Rhino

def get_first_curve(offset_result):
    if not offset_result:
        return None

    for crv in offset_result:
        if crv is not None:
            return crv

    return None


def extend_curve_on_surface(crv, surface):

    if crv is None:
        return None

    brep_face = surface.ToBrep().Faces[0]

    extended = crv.ExtendOnSurface(
        Rhino.Geometry.CurveEnd.Both,
        brep_face
    )

    if extended:
        return extended

    return crv


def recursive_offsets(curve, surface, distance, offsetsno, tolerance):

    left_curves = []
    right_curves = []

    # LEFT SIDE
    current = curve

    for i in range(offsetsno):

        result = Rhino.Geometry.Curve.OffsetOnSurface(
            current,
            surface,
            -distance,
            tolerance
        )

        current = get_first_curve(result)

        if current is None:
            break

        current = extend_curve_on_surface(
            current,
            surface
        )

        left_curves.append(current)

    left_curves.reverse()

    # RIGHT SIDE
    current = curve

    for i in range(offsetsno):

        result = Rhino.Geometry.Curve.OffsetOnSurface(
            current,
            surface,
            distance,
            tolerance
        )

        current = get_first_curve(result)

        if current is None:
            break

        current = extend_curve_on_surface(
            current,
            surface
        )

        right_curves.append(current)

    return left_curves + [curve.DuplicateCurve()] + right_curves


# Inputs:
# curve
# surface
# distance
# offsetsno
# tolerance

a = recursive_offsets(
    curve,
    surface,
    distance,
    int(offsetsno),
    tolerance
)

NetSrf2Crvs:

import Rhino.Geometry as rg
import System
from System import Int32
from clr import StrongBox

# Inputs:
# A : list of curves
# B : list of curves
# N : divisions

# Outputs:
# S : surfaces
# L : connector curves
# E : errors

S = []
L = []
E = []

N = max(1, int(N))
count = min(len(A), len(B))

for i in range(count):

    crvA = A[i]
    crvB = B[i]

    if not crvA or not crvB:
        continue

    a = crvA.DuplicateCurve()
    b = crvB.DuplicateCurve()

    a.Domain = rg.Interval(0, 1)
    b.Domain = rg.Interval(0, 1)

    curves = [a, b]

    # create connector curves
    for j in range(N + 1):

        t = float(j) / float(N)

        ptA = a.PointAt(t)
        ptB = b.PointAt(t)

        line = rg.Line(ptA, ptB).ToNurbsCurve()

        curves.append(line)
        L.append(line)

    curve_array = System.Array[rg.Curve](curves)

    error = StrongBox[Int32]()

    srf = rg.NurbsSurface.CreateNetworkSurface(
        curve_array,
        1,       # continuity
        0.01,    # edge tolerance
        0.01,    # interior tolerance
        0.01,    # angle tolerance
        error
    )

    E.append(error.Value)

    if srf:
        S.append(srf)

layercake facade recursive.gh (88.0 KB)

Where did ChatGPT enter into this?

Did you have it generate all the code you showed?

Hi @T_Reischl ,
My process is quite basic, I write to ChatGPT what i need, for example:
Create a python script for grasshopper that takes a curve and a surface, offsets the curve on the surface and extends it till the surface boundary, repeat the process recursively for the next curve.

Then I copy-paste the script written by ChatGPT in the Python GH component and set up the inputs. If i get an error i simply copy-paste the error from the terminal to ChatGPT.