v3 plugins
v3 vbscript
v2 vbscript
color match
convert curve equichordal
history hide
mesh mapper
open with V4
sel pts on crv

Mesh MappingConvert Curve Equichordal

This script will convert a curve to a given number of polyline which will all have the same length. For accuracy maniacs like me the end point is forced to fit exactly.

Interesting for scripters may be the approximation loop.

This script is ready to be copied into a button and should work with Rhino Version4 SR5 or higher.



-_RunScript (

Option Explicit
' Rationalize a Curve by a specified Number of equichordal line segments
' 3DE - Jess Maertterer - 23.10.2009

Sub ConvertCurveEquichord()
  Dim sCrv
  sCrv = Rhino.GetObject ("Select Curve to divide", 4, true, true)
  If IsNull(sCrv) Then Exit Sub
  Dim iSeg
  iSeg = Rhino.GetInteger ("Number of equidistant segments", 5, 2)
  If IsNull(iSeg) Then Exit Sub
  Dim dDist : dDist = Rhino.CurveLength(sCrv)/iSeg
  Dim dTol : dTol = Rhino.UnitAbsoluteTolerance()/2
  Dim dTooShort : dTooShort = 0
  Dim dTooLong : dTooLong = Rhino.CurveLength(sCrv)
  Dim aCrvEnd : aCrvEnd = Rhino.CurveEndPoint(sCrv)
  Dim aParam, aPt
  Rhino.Prompt "Dividing Curve... Press ESC to cancel"
    aParam = Rhino.DivideCurveEquidistant (sCrv, dDist, false,false)
    If ubound(aParam) = iSeg Then
      aPt = Rhino.EvaluateCurve(sCrv,aParam(ubound(aParam)))
      If Rhino.Distance(aPt,aCrvEnd)< dTol Then Exit Do
      dTooShort = dDist
      If ubound(aParam) < iSeg Then
        dTooLong = dDist
        dTooShort = dDist
      End If
    End If
    If (dTooLong-dTooShort) < 0.000000001 Then 
      Rhino.Print "Couldn't find a Solution with "&iSeg&" equidistant Segments!"
      Exit Sub
    End If
    dDist = dTooShort + (dTooLong-dTooShort)/2
    Rhino.StatusBarMessage (dDist)
  Dim arrPoints
  arrPoints = Rhino.DivideCurveEquidistant (sCrv, dDist, false,true)
  arrPoints(ubound(arrPoints))= aCrvEnd
  Rhino.SelectObject (Rhino.AddPolyline(arrPoints))
  Rhino.Print iSeg &" Segments at Distance: " & dDist
End Sub


© 3DE < ^ >