All Grasshopper enthusiasts that have follow the software development from earlier stages know the Shift Example, a case-study of the Shift List component (animation copyrighted by Robert McNeel & Associates).
While doing a research project in RhinoScript, I suddenly faced the need for a function like that one in my algorithm and a migration of tools wasn't so viable, so I developed a ShiftArray function that does exactly that in RhinoScript. You just have to input the array for
arrList and a shifting factor (as an integer) for
In my case, this was used to shift point locations for a correct loft surface between closed NURBS curves of different degrees; the transformations needed to be done before curve constructions, so the
CurveSeam method wouldn't work. But since is not explicitly dealing with Rhino geometry, just data, and arrays may storage any kind of data, it can be used for any wrapped array situation in any VBScript-based environment. Enjoy...
Function ShiftArray(ByVal arrList, ByVal s) Dim i, arrOut() ReDim arrOut(UBound(arrList)) ReDim Preserve arrList(UBound(arrList)+s) For i = 0 To s-1 arrList(UBound(arrList)-(s-1)+i) = arrList(i) Next For i = 0 To UBound(arrOut) arrOut(i) = arrList(i+s) Next ShiftArray = arrOut End Function