Hi,
first of all, Thanks, It is an incredible forum
@Jess
This script was rhino 3, but no longer works in rhino 5
I was wondering if you can still be recovered for reuse?
'
- creates a randomized copy of a surface
'Jess Maertterer - develop design - info@de-de.de - ďż˝ 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â
ma=vbnull
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
C0=Rhino.GetSurfacePointCount(CStr(ma))
CU=C0
If Rhino.IsSurfaceSingular (ma) Then
sxp ma
For I0=0 To C0(0)
Rhino.Command âNextUâ
Next
for I0=0 To C0(1)
Rhino.command âNextVâ
Next
rhino.Command âSmooth Enterâ
rhino.Command âPtOffâ
End if
Dim CO, M1, CurrentLocale
Rhino.SelectAllObjects vbfalse
Rhino.SetObjectSelect ma,vbtrue
Rhino.Command âExtractControlPolygonâ
M1=Rhino.GetLastObjectID
CurrentLocale = SetLocale(âen-usâ)
CO=Rhino.GetMeshVertices(M1)
Rhino.DeleteObject M1
Dim uc, vc
If IsArray(CO) Then
M1=UBound(CO, 2)
Else
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
next
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
else
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â
Next
Rhino.Command âNextVâ
If Not uc Then
For l1=0 To C0(0)-2
Rhino.Command âPrevUâ
Next
ENd If
Next
SetLocale(CurrentLocale)
Rhino.Command âSetRedrawOnâ
Rhino.Command âptoffâ
Rhino.Command âSelLastâ
End Sub
RandomSrf
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â
Next
for I0=2 to C0(1)
Rhino.Command âPrevVâ
Next
End Function
Function uid(srf, t1)
Rhino.Command âPtOffâ
Rhino.SelectAllObjects vbfalse
Rhino.SetObjectSelect srf,vbtrue
Rhino.Command âPtOnâ
Dim tx,ty,tz, tl
tx=t1(0,0)
ty=t1(1,0)
tz=t1(2,0)
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