Vb code don't work

Hello, i try to run this vb code but didn’t work in Rhino

And what is the equivalent of this with Python

Dim csx
  csx = Rhino.CurveSurfaceIntersection(crv, sphere)

  Rhino.DeleteObject sphere
  If Not IsArray(csx) Then Exit Function

  Dim i
  For i = 0 To UBound(csx)
    If csx(i,0) = 1 Then
      If (csx(i,5) > t) Then
        EquiDistantParameter = csx(i,5)
        Exit Function
      End If
    End If

Hi @anon39580149,

The code shown in the link is RhinoScript (e.g. VBScript), not VB. And the code does work in Rhino 7.

Here is the functional equivalent in Python:

import Rhino
import rhinoscriptsyntax as rs

def test_divide_curve_equiqdistant():
    crv_id = rs.GetObject('Select curve to divide', 4, True)
    if not crv_id: return
    crv_length = rs.CurveLength(crv_id)
    msg = 'Curve length is {0}. Division length'.format(crv_length)
    length = rs.GetReal(msg, 1.0)
    if not length: return
    if crv_length < length:
        print('Specified division length exceeds curve length.')
    crv = rs.coercecurve(crv_id)
    points = crv.DivideEquidistant(length)
    if points:
if __name__ == "__main__":

– Dale

1 Like

Thank you @dale
What i need is to use the idea of spheres in the VBScript to replace them with circles and don’t call DivideEquidistant directly.



– Dale

Because it’s already available in Grasshopper :slight_smile: ,and it is very slow with spheres.
I want test the original idea with circles.

Grasshopper does not use Curve.DivideEquidistant.

– Dale

Am i miss something?

Like I said, the Divide Distance component does not call Curve.DivideEquidistant.

What is the differenece between divide distance component and Curve.DivideEquidistant in GhPython?
I read in the old forum that divide component use spheres to find points like in the vbscript.

I find a solution, Thank you.

def EquiDistantParameter(crv, t, length):
    EquiDistantParameter = None
    pt = rs.EvaluateCurve(crv,t)
    #sphere = rs.AddSphere(pt,length)
    #csx = rs.CurveSurfaceIntersection(crv,sphere)
    circle = rs.AddCircle(pt,length)
    csx = rs.CurveCurveIntersection(crv,circle)
    for i in csx:
        if i[0] == 1:
            if i[5]>t:
                EquiDistantParameter = i[5]
    return EquiDistantParameter

crv_length = crv.GetLength()
length = d
dom = crv.Domain
t = dom[0]
pt = crv.PointAt(t)
bdone = False
points = [crv.PointAtStart]

while bdone == False:
    t = EquiDistantParameter(crv, t, length)
    if not t:
        bdone = True
        pt = crv.PointAt(t)


How about this?


– Dale

Comparing results with the code is better, i can’t know from the image.


Thanks, did you update the code of Curve.DivideEquidistant?
I don’t know if it is much faster now or not , but it is faster than the regular component

With code using circles it is faster but don’t work with self intersected or spiral curve

This is a test with the version 7.9.21162.15001
Divide distance work faster with 3d curve !

test.gh (6.2 KB)

1 Like

nice work Seghier!!

1 Like