HELP - Py script for OffsetCrvonSrf

Hi folks,
I need a big Help.
I’m starting learning how to script Py in GH.
I want to build a better OffsetCrvOnSrf because the orignal GH component looks worst than the Rhino one.
The idea is to call the Rhino one and iterate the offst of the last created crv many times.

This my script:

import Rhino
import ghpythonlib.treehelpers as th

i= 0
Curves = []
Crvs=[]
LayerTree = []

for i in Distances:
    Curve = Rhino.Geometry.Curve.OffsetOnSurface(Curve, Surface, i, 0.005)
    Crvs.append(Curve)
 
layerTree = th.list_to_tree(Crvs, source=[0,0])
Curves = layerTree

Unfortunately I get this error:

Runtime error (ArgumentTypeException): expected Curve, got Array[Curve]

Traceback:
line 20, in script.

Could you pls help me?
Thanks in advance.
Riccardo

Hello,
It is telling you that in line 20 it expects a curve object but actually gets a list - how do you initialise Curve? You could try one of the following solutions:

  • try Curve = Rhino.Geometry.Curve.OffsetOnSurface(Curve[0], Surface, i, 0.005)
  • switch curve from a list input to a single object input
  • add a loop for curve in curves to loop over multiple input curves and offset them all.

Thanks, but I can’t make it working.
Here’s the original script maybe is a problem on how I set the input Type.
If you have the chance to give it a look I would really appreciate it.

20230412_Offset_Py_custom.gh (9.3 KB)

Help pls.

Your Curve variable seems to represent an array of curves, a list, whereas Rhino.Geometry.Curve.OffsetOnSurface expects a single curve to offset!

Simply change the loop to a nested one.

for i in Distances:
    for crv in Curve:
        Crvs.append
            Rhino.Geometry.Curve.OffsetOnSurface(crv, Surface, i, 0.005)
        )

You’re geometry wasn’t internalized, which is why I couldn’t really test this.

Thanks.
Apologize for not giving you the geometry.
The problem is that it doesn’t work neither with a single crv.
Reading the output it says “multiplecrv” object.
Do you advise me how to convert a multiple crv into a single crv?
I tried rebuild but nothing.

I’ll upload the geometry asap .
Thanks