A pool of resources
Dash Curve

    


A simple script developed during the Rib maker script, this Rhinoscript interface allows the user to select a set of curves then input a sequential set of curve parameters between 0 and 1. The curve set is then broken according to the sequential parameters.


platform: Rhino Script
function: Modeling Aid

 


Option Explicit
'Script written by <David Mans>
'Script copyrighted by <Neoarchaic Studio>
'Script version Monday, April 27, 2009 9:56:55 PM

Call Main()
Sub Main()

	Dim arrCurves: arrCurves = Rhino.GetObjects("Select Curve",4,True)
	If isnull(arrCurves) Then Exit Sub

	Dim a, b, c, i
	Dim arrSet()

	a = Rhino.GetReal ("Parameter A.0 (0<x>1)" , 0, 0, 1)
	If isNull(a) Then Exit Sub
	Do
		If i > 0 Then
			c = Rhino.GetReal ("Parameter A." & i & " (" & a & "< x > 1)" , a, a, 1)
			If isNull(c) Or c = a Or c = 1 Then Exit Do
		Else
			c = a
		End If

		b = Rhino.GetReal ("Parameter B." & i & " (" & c & "< x > 1)" , c, c, 1)
		If isNull(b) Or b = c Or b = 1 Then Exit Do
		a = b

		ReDim Preserve arrSet(i)
		arrSet(i) = array(CDbl(c),CDbl(b))

		i = i+1
	Loop

	If b = 0 Then Exit Sub

	Call Rhino.EnableRedraw(False)
	For i = 0 To uBound(arrCurves) Step 1
		reparameterize(arrCurves(i))
		Call removeSegment(arrCurves(i),arrSet)
	Next
	Call Rhino.EnableRedraw(True)
End Sub
Function removeSegments(strCurve,arrParams)
	removeSegments = Null
	Dim arrOutput()
	Dim i, r, curve, crv, keep

	i = 0
	r = 0
	keep = strCurve
	Do
		curve = Rhino.SplitCurve(keep,arrParams(i)(0),True)
		If uBound(curve) = 0 Then
			crv = Rhino.SplitCurve(curve(0),arrParams(i)(1),True)
		Else
			crv = Rhino.SplitCurve(curve(1),arrParams(i)(1),True)
		End If
		Call Rhino.DeleteObject(crv(0))

		ReDim Preserve arrOutput(r)
		arrOutput(r) = curve(0)
		r = r+1

		If uBound(curve) = 0 Then
			If i = 0 Then
				r = 0
			Else
				Exit Do
			End If
		End If

		If i = uBound(arrParams) And uBound(crv) > 0 Then
			ReDim Preserve arrOutput(r)
			arrOutput(r) = crv(1)
		End If
		i = i+1
		If i = uBound(arrParams)+1 Then Exit Do
		keep = crv(1)
	Loop

	removeSegments = arrOutput
End Function
Function reparameterize(strCurveID)
	If Rhino.IsCurve(strCurveID) = True Then
		Call rhino.SelectObject(strCurveID)
		Call rhino.Command("reparameterize 0 1")
		Call rhino.UnselectAllObjects()
	End If
	If Rhino.IsSurface(strCurveID) = True Then
		Call rhino.SelectObject(strCurveID)
		Call rhino.Command("reparameterize 0 1 0 1")
		Call rhino.UnselectAllObjects()
	End If
End Function


Reply