This script can be recovered for rhino 5? RandomSrf or all of the button :)


first of all, Thanks, It is an incredible forum

This script was rhino 3, but no longer works in rhino 5
I was wondering if you can still be recovered for reuse?

':smiley: - creates a randomized copy of a surface
’Jess Maertterer - develop design - - � 17.06.2002
public ddx,ddy,ddz
Sub RandomSrf
Rhino.Command "PtOff"
Dim ma
ma=Rhino.GetObjectId("Select surface to randomize ",8)
If Not IsNull(ma) Then
Rhino.SetObjectSelect ma,vbtrue
If Not Rhino.IsSurface(ma) Then
MsgBox "Selected surface is part of a polysurface"
End If
End If
If Not Vartype(ma)=VBstring then exit sub
Rhino.SelectAllObjects vbfalse
ma=Rhino.CopyObject (ma)
Rhino.SetObjectSelect ma,vbtrue
Dim C0, CU, I0
If Rhino.IsSurfaceSingular (ma) Then
sxp ma
For I0=0 To C0(0)
Rhino.Command "NextU"
for I0=0 To C0(1)
Rhino.command "NextV"
rhino.Command "Smooth Enter"
rhino.Command "PtOff"
End if
Dim CO, M1, CurrentLocale
Rhino.SelectAllObjects vbfalse
Rhino.SetObjectSelect ma,vbtrue
Rhino.Command "ExtractControlPolygon"
CurrentLocale = SetLocale(“en-us”)
Rhino.DeleteObject M1
Dim uc, vc
If IsArray(CO) Then
M1=UBound(CO, 2)
Exit Sub
End If
For I0=1 to M1
If CO(0,0)=CO(0,I0) And CO(1,0)=CO(1,I0) And CO(2,0)=CO(2,I0) Then
If I0 < C0(0) ANd C0(0)=CU(0) Then C0(0)=I0 +1 : uc=vbtrue
If I0 > C0(0) and C0(1)=CU(1) Then C0(1)=((M1 + 1) / (C0(0))) : vc=vbtrue
End If
Dim O0, l1, RF, S1,mx,my,mz
If Not Vartype(ddx)=vbdouble then ddx=1
If Not Vartype(ddy)=vbdouble then ddy=1
If Not Vartype(ddz)=vbdouble then ddz=1
ddx=Rhino.GetReal ("max X movement � ",ddx)
ddy=Rhino.GetReal ("max Y movement � ",ddy)
ddz=Rhino.GetReal ("max Z movement � “,ddz)
If uc or vc then
uid ma, CO
iud ma,C0
end If
Rhino.Command “SetRedrawOff"
For O0=0 To (C0(1)-1)
For l1=0 To (C0(0)-1)
mx=(rnd-0.5)*ddx * 2
my=(rnd-0.5)*ddy * 2
mz=(rnd-0.5)*ddz * 2
If Not ((l1=C0(0)-1) and uc) then
if not ((O0=C0(1)-1) and vc) then
S1=“Move 0,0,0 “&mx&”,”&my&”,”&mz
Rhino.Command S1
End If
End If
If l1 < (C0(0)-1) then Rhino.Command "NextU"
Rhino.Command "NextV"
If Not uc Then
For l1=0 To C0(0)-2
Rhino.Command "PrevU"
ENd If
Rhino.Command "SetRedrawOn"
Rhino.Command "ptoff"
Rhino.Command "SelLast"
End Sub
Function sxp (srf)
Rhino.Command "PtOff"
Rhino.SelectAllObjects vbfalse
Rhino.SetObjectSelect srf,vbtrue
Rhino.Command "PtOn"
Rhino.Command "InvertPt"
End Function
Function iud(srf, C0)
Dim I0
sxp (srf)
For I0=2 to C0(0)
Rhino.Command “PrevU"
for I0=2 to C0(1)
Rhino.Command “PrevV"
End Function
Function uid(srf, t1)
Rhino.Command “PtOff"
Rhino.SelectAllObjects vbfalse
Rhino.SetObjectSelect srf,vbtrue
Rhino.Command “PtOn"
Dim tx,ty,tz, tl
tl=“PlaceTarget w”&tx&”,”&ty&”,”&tz
Rhino.Command tl
Rhino.Command "CPlaneToView"
Rhino.Command "SelWindow -0.001,-0.001 0.001,0.001"
Rhino.Command "CplanePrev"
Rhino.Command "ZoomPrev"
End Function

I have been using another form of deforming the surface but this script “randomSrf” seems very practical
more complex shapes to


Hi Victor,
You’re welcome!

Of course these functions can be made with Rhino V5. Probably slightly improved since 14 years of development left some marks on the SDKs :smiley:

Unfortunately I do not have any time left at the moment to help you. But I seem to remember that similar scripts have been discussed here. You may search the scripting forum or someone else will jump in and point you in the right direction.

And of course Grasshopper would be great for that, cause it can display a dynamic preview while you tweak the parameters.

Good Luck,


@vikthor @Jess,

here is an old one i’ve done some years ago: GripRandomize.rvb (13.1 KB)

Works with curves, surfaces or meshes and randomly transforms object grips. If no grips are pre-selected, all grips are randomly transformed. To randomize only a few grips, just preselect the ones you want, then click on the object.

The script allows to set various variables, eg. the transform direction and distance…

Oh yeah, greetings !



thank you very much, you are excellent developers

the script GripRandomize.rvb , I already knew

what I want is to achieve the same as in the gif that a particular area is selected to work without deforming the whole object.


@vikthor, this should work if you turn points on and select only the grips (control points) in the area you like to deform. The script then still asks for the object and starts deforming the selection. Do you see something different ?



this is what I have achieved so far,
not let me option to select control points

and I can not equal deformation in the examples
It is more rigid

trying to match the example with the same number of control points, I can not get the result


Yes i see now. You have to pre-select the controlpoints you would like to deform, then start the script, then it asks for the object. To get the same deformation direction as in the script from Jess, use the XYZ option.

Any better now ?



yes, that is thank you very much,
although it requires many more control points, but okay

I have another question a little differently,
the commando twist no way to add the amount of turns, not to be turning manually
or a script to do that?


@vikthor, if you mean the _Twist command and want to enter the turns (when Rhino asks for the angle), you have to multilpy it by 360 to get the angle, eg. 4.5 turns would be 4.5*360 = 1620. It maybe helps to open _Calc before starting the _Twist command, make the calculation of the angle there and then click the GO button once the twist command asks for the angle.

btw. in Rhino 6 Wip you can directly enter 4.5*360 into the commandline and it does the math for that angle automatically.



Thanks great, rhino 5 so does direct the command line;
but it is a bit like excel, I did not know what the angle wondering why, but I made formulas in rhino 5 as follows:

= (4.5 * 360) so that also automatically calculates the angle
I’m glad to know that the rhino 6 was simplified. :slight_smile:

Thank you so much @clement