Hi
I’ve been using this script for unrolling multiple surfaces, copiing it ran only as administrator in Rhino 7 and now that i use Rino 8 the script just stopped working. Note that the script is originally written in .rvb so i wonder if it is possible to rewrite it for python
Here is the Script:
Option Explicit
'Script written by Jaroslaw Bieda
Call Main()
Sub Main()
On Error Resume Next
'get surfaces to unroll
Dim arrM : arrM = Rhino.GetObjects("Surfaces to Unroll?", 8)
If isnull(arrM) Then Exit Sub
'get unroll start point
Dim arrBP : arrBP = Rhino.GetPoint("Unroll start point?")
If isnull(arrBP) Then arrBP = array(0, 0, 0)
Dim x : x = 0
Dim arrBB
Dim idM
Dim i,j,arrMV,arrDots(),arrNewMV(),arrUnrolled, idNewMesh
Dim c : c = 0
Dim arrNewMeshes()
Dim strTmpPath : strTmpPath = GetApplicationDataFolder() & "tmp.obj"
Call Rhino.EnableRedraw(False)
Call Rhino.StatusBarProgressMeter("Processing...", 0, Ubound(arrM), True, True)
'process each surface
For i=0 To Ubound(arrM)
Call Rhino.StatusBarProgressMeter(i)
If Rhino.IsSurfaceUnrollable(arrM(i)) Then
'get underlying mesh
idM = Rhino.ExtractRenderMesh(arrM(i))
Rhino.UnselectAllObjects
'export/import as OBJ to 'Bake' texture coordinates
Call Rhino.SelectObject(idM)
Call Rhino.Command("-_Export " & strTmpPath & " _ExportMeshTextureCoordinates=Yes _Enter _Enter", False)
Call Rhino.DeleteObject(idM)
Call Rhino.Command("_-Import " & strTmpPath & " _Enter", False)
idM = Rhino.SelectedObjects()(0)
'draw dot for each mesh vertex with number on the source surface
arrMV = Rhino.MeshVertices(idM)
ReDim arrDots(Ubound(arrMV))
For j=0 To Ubound(arrMV)
arrDots(j) = Rhino.AddTextDot(Cstr(j), Rhino.EvaluateSurface(arrM(i), Rhino.SurfaceClosestPoint(arrM(i), arrMV(j))))
Next
'select original surface and dots from mesh verts
Call Rhino.UnselectAllObjects()
Call Rhino.SelectObjects(arrDots)
Call Rhino.SelectObject(arrM(i))
'unroll...
Call Rhino.Command("_UnrollSrf _Labels=No _Enter", False)
'reconstructing mesh vertext locations from dots
ReDim arrNewMV(Ubound(arrMV))
arrUnrolled = Rhino.LastCreatedObjects()
For j=0 To Ubound(arrUnrolled)
If Rhino.ObjectType(arrUnrolled(j)) = 8192 Then
arrNewMV(CInt(Rhino.TextDotText(arrUnrolled(j)))) = Rhino.TextDotPoint(arrUnrolled(j))
End If
Next
'reconstruct unrolled mesh based on original vertices and text. coords
idNewMesh = Rhino.AddMesh(arrNewMV, Rhino.MeshFaceVertices(idM),, Rhino.MeshTextureCoordinates(idM))
Call Rhino.MatchMaterial(arrM(i), array(idNewMesh))
ReDim Preserve arrNewMeshes(c)
arrNewMeshes(c) = idNewMesh
c = c + 1
'move mesh no the new unroll location / arrange
arrBB = Rhino.BoundingBox(idNewMesh)
Call Rhino.MoveObject(idNewMesh, arrBB(0), array(arrBP(0) + x, arrBP(1), arrBP(2)))
x = x + Rhino.Distance(arrBB(0), arrBB(1))
'cleanup
Call Rhino.DeleteObjects(arrUnrolled)
Call Rhino.DeleteObject(idM)
Call Rhino.DeleteObjects(arrDots)
'refresh view
Call Rhino.EnableRedraw(True)
Call Rhino.EnableRedraw(False)
Else 'mark non-unrollable surface as RED
Call Rhino.ObjectColor(arrM(i), vbRed)
End If
Next
'finalize
Call Rhino.UnselectAllObjects()
If c > 0 Then Call Rhino.SelectObjects(arrNewMeshes)
Call Rhino.EnableRedraw(True)
Call Rhino.StatusBarProgressMeter()
End Sub
Private Function GetApplicationDataFolder()
Const APPLICATION_DATA = &H1a&
Dim objShell, objFolder, objFolderItem
Set objShell = CreateObject(“Shell.Application”)
Set objFolder = objShell.Namespace(APPLICATION_DATA)
Set objFolderItem = objFolder.Self
GetApplicationDataFolder = objFolderItem.Path & “”
End Function