Mr. Blue Balls
Maya Paint - RhinoScript Research V.1 [02.March.2011] - via Maya + Rhino

Research and Development by Luis Quinones + Dave Stamatis
Triangle Terminator
Quad Mesh Vertex Color Info
Quad + Tri Mesh Vertex Color Info

Research and Development by Luis Quinones + Dave Stamatis
Triangle Terminator
'Run this script before painting to remove all nSided Polygons
Option Explicit
'Script written by Luis Quinones
'Script copyrighted by [n]igma + studioBoom
'www.luisquinonesdesign.com
'www.cargocollective.com/studioboom
'Script version Monday, 21 March 2011 20:18:46
Call Main()
Sub Main()
'Dim strMesh : strMesh = Rhino.GetObject("SOLIDMESH",32,,True)
Call Rhino.Command("_selmesh")
Call Rhino.Command("unweld 0")
Call Rhino.Command("explode")
Call Rhino.Command("Ungroup")
Dim arrMesh : arrMesh = Rhino.GetObjects("MESHES",32,True)
Dim i
Dim strLayer : strLayer = Rhino.AddLayer("TRI")
Call Rhino.EnableRedraw(False)
For i = 0 To Ubound(arrMesh)
Dim meshVert : meshVert = Rhino.MeshVertices(arrMesh(i))
If Not Ubound(meshVert) = 3 Then
Call Rhino.ObjectLayer(arrMesh(i),strLayer)
End If
Next
Call Rhino.layerVisible(strLayer,False)
Call Rhino.EnableRedraw(True)
End Sub
Quad Mesh Vertex Color Info
Option Explicit
'Script written by Luis Quinones
'Script copyrighted by [n]igma + studioBoom
'www.luisquinonesdesign.com
'www.cargocollective.com/studioboom
'Script version Sunday, March 20, 2011 8:08:03 PM
Call Main()
Sub Main()
'///////////////////////////////////////////////////////////////////////////////////////////////////
Call Rhino.MessageBox("Code Generates Mesh OffSets and Frames Based on Luminance Values coming from Geometry Painted with PaintVertex Tool in Maya")
'Declare Variables
Dim strMainLayer : strMainLayer = Rhino.AddLayer("MainMesh")
Dim strObject : strObject = Rhino.GetObject("Select mesh", 32)
Call Rhino.ObjectLayer(strObject,strMainLayer)
MeshFaces
Dim arrFaces : arrFaces = Rhino.MeshFaces(strObject, True)
Dim color : color = Rhino.MeshVertexColors(strObject)
Dim arrFace(3),arrHLS(3)
Dim arrFaceVertices2()
Dim strLayer6 : strLayer6 = Rhino.AddLayer("BaseCrvs",RGB(255,0,0))
Dim strLayer2 : strLayer2 = Rhino.AddLayer("OffsetCrv",RGB(255,0,0))
Dim strLayer : strLayer = Rhino.AddLayer("OffSetMesh",RGB(255,0,0))
Dim strLayer3 : strLayer3 = Rhino.AddLayer("FrameDog",RGB(255,255,255))
Dim strLayer5 : strLayer5 = Rhino.AddLayer("0_ValueOffSet",RGB(120,120,120))
Dim strLayer4 : strLayer4 = Rhino.AddLayer("Color_Vert_Info",RGB(255,255,0))
Dim i,j
'///////////////////////////////////////////////////////////////////////////////////////////////////
If IsArray(arrFaces) Then
Rhino.EnableRedraw False
i = 0
Do While i <= UBound(arrFaces)
arrFace(0) = arrFaces(i)
arrFace(1) = arrFaces(i+1)
arrFace(2) = arrFaces(i+2)
arrFace(3) = arrFaces(i+3)
arrHLS(0) = Rhino.ColorRGBToHLS(color(i))
'Call Rhino.Print(arrHLS(0)(1)/240)
arrHLS(1) = Rhino.ColorRGBToHLS(color(i+1))
'Call Rhino.Print(arrHLS(1)(1)/240)
arrHLS(2) = Rhino.ColorRGBToHLS(color(i+2))
'Call Rhino.Print(arrHLS(2)(1)/240)
arrHLS(3) = Rhino.ColorRGBToHLS(color(i+3))
'Call Rhino.Print(arrHLS(3)(1)/240)
'Call Rhino.AddTextDot("Vert 0" & "_" & arrHLS(0)(1)/240,arrface(0))
'Call Rhino.AddTextDot("Vert 1" & "_" & arrHLS(1)(1)/240,arrface(1))
'Call Rhino.AddTextDot("Vert 2" & "_" & arrHLS(2)(1)/240,arrface(2))
'Call Rhino.AddTextDot("Vert 3" & "_" & arrHLS(3)(1)/240,arrface(3))
Dim sum : sum = Rhino.Sum(Array(arrHLS(0)(1)/240,arrHLS(1)(1)/240,arrHLS(2)(1)/240,arrHLS(3)(1)/240))
Dim ave : ave = sum/4
'If ave < 0.015 Then
'ave = 0.015
'End If
'Call Rhino.Print(ave)
Dim line : line = Rhino.AddLine(arrFace(0),arrFace(2))
Dim midpt : midpt = Rhino.CurveMidPoint(line)
Call Rhino.DeleteObject(line)
'Dim dot1 : dot1 = Rhino.AddTextDot("Scale_Value = " & ave,midpt)
'Call Rhino.ObjectLayer(dot1,strLayer4)
Dim arrVertices : arrVertices = Array(arrFace(0),arrFace(1),arrFace(2),arrFace(3))
Dim arrVerticesNEW : arrVerticesNEW = Array(arrFace(0),arrFace(1),arrFace(2),arrFace(3),arrFace(0)) '///////////////////////////////////////////////////////////////////////////////////////////////////
For j = 0 To 3
ReDim Preserve arrFaceVertices2(j)
arrFaceVertices2(j) = Array(0,1,2,3)
Next
'///////////////////////////////////////////////////////////////////////////////////////////////////
Dim newMesh : newMesh = Rhino.AddMesh (arrVertices, arrFaceVertices2)
Call Rhino.ObjectLayer(newMesh,strLayer5)
Dim meshCent : meshCent = Rhino.MeshAreaCentroid(newMesh)
Dim strPoly : strPoly = Rhino.AddPolyline(arrVerticesNEW)
Call Rhino.ObjectLayer(strPoly,strLayer6)
Dim strPoly2 : strPoly2 = Rhino.AddPolyline(arrVerticesNEW)
Call Rhino.ObjectLayer(strPoly2,strLayer6)
'/////////////////////////////////////////////////////////////////////////////////////////////////
If ave > 0 And ave < 0.9 Then
Dim scaleMesh : scaleMesh = Rhino.ScaleObject(newMesh,meshCent,Array(ave,ave,ave))
Call Rhino.ObjectLayer(scaleMesh,strLayer)
Dim scaleSrf : scaleSrf = Rhino.ScaleObject(strPoly,meshCent,Array(ave,ave,ave))
Call Rhino.ObjectLayer(scaleSrf,strLayer2)
Dim strlofty : strlofty = Rhino.AddLoftSrf(Array(strPoly2,scaleSrf))
Call Rhino.ObjectLayer(strLofty,strLayer3)
Call Rhino.SurfaceIsocurveDensity(strlofty,-1)
'Call Rhino.DeleteObjects(join)
End If
'///////////////////////////////////////////////////////////////////////////////////////////////////
If ave >= 0.9 Then
Dim scaleMesh3 : scaleMesh3 = Rhino.ScaleObject(newMesh,meshCent,Array(ave-0.05,ave-0.05,ave-0.05))
Call Rhino.ObjectLayer(scaleMesh3,strLayer)
Dim scaleSrf3 : scaleSrf3 = Rhino.ScaleObject(strPoly,meshCent,Array(ave-0.05,ave-0.05,ave-0.05))
Call Rhino.ObjectLayer(scaleSrf3,strLayer2)
strlofty = Rhino.AddLoftSrf(Array(strPoly2,scaleSrf3))
Call Rhino.ObjectLayer(strLofty,strLayer3)
Call Rhino.SurfaceIsocurveDensity(strlofty,-1)
'Call Rhino.DeleteObjects(join3)
End If
i = i + 4
Erase arrFaceVertices2
Loop '///////////////////////////////////////////////////////////////////////////////////////////////////
Rhino.EnableRedraw True
End If
Call Rhino.LayerVisible(strLayer2,False)
Call Rhino.LayerVisible(strLayer4,False)
Call Rhino.LayerVisible(strMainLayer,False)
Call Rhino.LayerVisible(strLayer6,False)
End Sub
Quad + Tri Mesh Vertex Color Info
Option Explicit
'Script written by
'Script copyrighted by <[n]igma>
'www.luisquinonesdesign.com
'www.cargocollective.com/studioboom
'Script version Sunday, March 20, 2011 8:08:03 PM
Call Main()
Sub Main()
'///////////////////////////////////////////////////////////////////////////////////////////////////
Call Rhino.MessageBox("Code Generates Mesh OffSets and Frames Based on Luminance Values coming from Geometry Painted with PaintVertex Tool in Maya")
'Declare Variables
Dim strMainLayer : strMainLayer = Rhino.AddLayer("BaseColorMesh")
Dim strObject : strObject = Rhino.GetObject("Select mesh", 32)
Call Rhino.ObjectLayer(strObject,strMainLayer)
MeshFaces
Dim arrFaces : arrFaces = Rhino.MeshFaces(strObject, True)
Dim color : color = Rhino.MeshVertexColors(strObject)
'619
Dim arrFace(3),arrHLS(3),triarrHLS(2)
Dim arrFaceVertices2(),triarrFaceVertices2()
Dim strLayer6 : strLayer6 = Rhino.AddLayer("BaseCrvs",RGB(255,0,0))
Dim strLayer : strLayer = Rhino.AddLayer("Quad_OffSetMesh")
Dim strLayer7 : strLayer7 = Rhino.AddLayer("Tri_OffSetMesh")
Dim strLayer2 : strLayer2 = Rhino.AddLayer("Frame_Inner",RGB(255,0,0))
Dim strLayer3 : strLayer3 = Rhino.AddLayer("Frame_OutterDog",RGB(255,255,255))
Dim strLayer5 : strLayer5 = Rhino.AddLayer("Frame_0_ValueOffset")
Dim strLayer4 : strLayer4 = Rhino.AddLayer("Color_Vert_Info",RGB(255,255,0))
'Dim strLayer6 : strLayer6 = Rhino.AddLayer("Tri_Color_VertInfo")
Dim i,j,k
Dim counter(),count,count2
'///////////////////////////////////////////////////////////////////////////////////////////////////
If IsArray(arrFaces) Then
Rhino.EnableRedraw False
count = 0
count2 = 0
i = 0
Dim testcount : testcount = 0
'///////////////////////////////////////////////////////////////////////////////////////////////////
Do While i <= Ubound(arrFaces)
arrFace(0) = arrFaces(count)
arrFace(1) = arrFaces(count+1)
arrFace(2) = arrFaces(count+2)
arrFace(3) = arrFaces(count+3)
'Call Rhino.Print(arrFace(2)(0))
'Call Rhino.Print(arrFace(3)(0))
If arrFace(2)(0) = arrFace(3)(0) Then
arrHLS(0) = Rhino.ColorRGBToHLS(color(count2))
'Call Rhino.Print(arrHLS(0)(1)/240)
arrHLS(1) = Rhino.ColorRGBToHLS(color(count2+1))
'Call Rhino.Print(arrHLS(1)(1)/240)
arrHLS(2) = Rhino.ColorRGBToHLS(color(count2+2))
'Call Rhino.Print(arrHLS(2)(1)/240)
arrHLS(3) = Rhino.ColorRGBToHLS(color(count2+2))
'Call Rhino.Print(arrHLS(3)(1)/240)
ReDim Preserve counter(testcount)
counter(testcount) = 0
'Call Rhino.Print("HAS MATCH")
'Call Rhino.AddTextDot("TVert " & i ,arrFace(0))
'Call Rhino.AddTextDot("TVert " & i,arrFace(1))
'Call Rhino.AddTextDot("TVert " & i,arrFace(2))
'Call Rhino.AddTextDot("TVert " & i,arrFace(3))
testcount = testcount + 1 '///////////////////////////////////////////////////////////////////////////////////////////////////
Dim trisum : trisum = Rhino.Sum(array(arrHLS(0)(1)/240,arrHLS(1)(1)/240,arrHLS(2)(1)/240,arrHLS(3)(1)/240))
Dim triave : triave = trisum/4
If triave < 0.02 Then
triave = 0
End If
Dim refLine : refLine = Rhino.AddLine(arrFace(1),arrFace(2))
Dim refMid : refMid = Rhino.CurveMidPoint(refLine)
Dim triline : triline = Rhino.AddLine(arrFace(0),refMid)
Dim trimidpt : trimidpt = Rhino.CurveMidPoint(triline)
Call Rhino.DeleteObject(triline)
Dim tridot1 : tridot1 = Rhino.AddTextDot("Scale_Value = " & triave,trimidpt)
Call Rhino.ObjectLayer(tridot1,strLayer4)
Dim trivert : triVert = array(arrFace(0),arrFace(1),arrFace(2),arrFace(3))
For k = 0 To 3
ReDim Preserve triarrFaceVertices2(k)
triarrFaceVertices2(k) = Array(0,1,2,2)
Next '///////////////////////////////////////////////////////////////////////////////////////////////////
Dim trinewMesh : trinewMesh = Rhino.AddMesh (trivert, triarrFaceVertices2)
Dim trimeshCent : trimeshCent = Rhino.MeshAreaCentroid(trinewMesh)
Dim triSrf : triSrf = Rhino.AddSrfPt(trivert)
Dim srfCent : srfCent = Rhino.SurfaceAreaCentroid(triSrf)
Dim newdup : newdup = Rhino.DuplicateEdgeCurves(triSrf)
Dim newjoin : newjoin = Rhino.JoinCurves(newdup)
Call Rhino.DeleteObjects(newdup)
'///////////////////////////////////////////////////////////////////////////////////////////////////
If triave = 0 Then
Dim triscale2 : triscale2 = Rhino.ScaleObject(trinewMesh,trimeshCent,array(1,1,1))
Call Rhino.ObjectLayer(triscale2,strLayer7)
Dim triscaleSrf3 : triscaleSrf3 = Rhino.ScaleObject(triSrf,srfCent(0),array(1,1,1))
Call Rhino.ObjectLayer(triscaleSrf3,strLayer5)
Call Rhino.SurfaceIsocurveDensity(triScaleSrf3,-1)
Dim tridupEdge : tridupEdge = Rhino.DuplicateEdgeCurves(triscaleSrf3)
Dim trijoin : trijoin = Rhino.JoinCurves(tridupEdge)
Call Rhino.DeleteObjects(tridupEdge)
Call Rhino.DeleteObjects(trijoin)
End If '///////////////////////////////////////////////////////////////////////////////////////////////////
If triave > 0 Then
Dim triscale3 : triscale3 = Rhino.ScaleObject(trinewMesh,trimeshCent,array(triave,triave,triave))
Call Rhino.ObjectLayer(triscale3,strLayer7)
Dim scaleSrfA : scaleSrfA = Rhino.ScaleObject(triSrf,srfCent(0),array(triave,triave,triave))
Call Rhino.ObjectLayer(scaleSrfA,strLayer2)
Call Rhino.SurfaceIsocurveDensity(scaleSrfA,-1)
tridupEdge = Rhino.DuplicateEdgeCurves(scaleSrfA)
trijoin = Rhino.JoinCurves(tridupEdge)
Call Rhino.DeleteObjects(tridupEdge)
Dim tristrlofty : tristrlofty = Rhino.AddLoftSrf(array(newjoin(0),trijoin(0)))
Call Rhino.ObjectLayer(tristrlofty,strLayer3)
Call Rhino.SurfaceIsocurveDensity(tristrlofty,-1) Call Rhino.DeleteObjects(trijoin)
End If '///////////////////////////////////////////////////////////////////////////////////////////////////
count2 = count2 + 3
'///////////////////////////////////////////////////////////////////////////////////////////////////
Else '///////////////////////////////////////////////////////////////////////////////////////////////////
arrHLS(0) = Rhino.ColorRGBToHLS(color(count2))
'Call Rhino.Print(arrHLS(0)(1)/240)
arrHLS(1) = Rhino.ColorRGBToHLS(color(count2+1))
'Call Rhino.Print(arrHLS(1)(1)/240)
arrHLS(2) = Rhino.ColorRGBToHLS(color(count2+2))
'Call Rhino.Print(arrHLS(2)(1)/240)
arrHLS(3) = Rhino.ColorRGBToHLS(color(count2+3))
'Call Rhino.Print(arrHLS(3)(1)/240)
Dim sum : sum = Rhino.Sum(array(arrHLS(0)(1)/240,arrHLS(1)(1)/240,arrHLS(2)(1)/240,arrHLS(3)(1)/240))
Dim ave : ave = sum/4
If ave < 0.02 Then
ave = 0
End If
'Call Rhino.Print(ave)
Dim line : line = Rhino.AddLine(arrFace(0),arrFace(2))
Dim midpt : midpt = Rhino.CurveMidPoint(line)
Call Rhino.DeleteObject(line)
Dim dot1 : dot1 = Rhino.AddTextDot("Scale_Value = " & ave,midpt)
Call Rhino.ObjectLayer(dot1,strLayer4)
Dim arrVertices : arrVertices = Array(arrFace(0),arrFace(1),arrFace(2),arrFace(3))
Dim arrVerticesNEW : arrVerticesNEW =
Array(arrFace(0),arrFace(1),arrFace(2),arrFace(3),arrFace(0))
For j = 0 To 3
ReDim Preserve arrFaceVertices2(j)
arrFaceVertices2(j) = Array(0,1,2,3)
Next
Dim newMesh : newMesh = Rhino.AddMesh (arrVertices, arrFaceVertices2)
Call Rhino.ObjectLayer(newMesh,strLayer5)
Dim meshCent : meshCent = Rhino.MeshAreaCentroid(newMesh)
Dim strPoly : strPoly = Rhino.AddPolyline(arrVerticesNEW)
Call Rhino.ObjectLayer(strPoly,strLayer6)
Dim strPoly2 : strPoly2 = Rhino.AddPolyline(arrVerticesNEW)
Call Rhino.ObjectLayer(strPoly2,strLayer6)
If ave > 0 And ave < 0.9 Then
Dim scaleMesh : scaleMesh =
Rhino.ScaleObject(newMesh,meshCent,Array(ave,ave,ave))
Call Rhino.ObjectLayer(scaleMesh,strLayer)
Dim scaleSrf : scaleSrf =
Rhino.ScaleObject(strPoly,meshCent,Array(ave,ave,ave))
Call Rhino.ObjectLayer(scaleSrf,strLayer2)
Dim strlofty : strlofty = Rhino.AddLoftSrf(Array(strPoly2,scaleSrf))
Call Rhino.ObjectLayer(strLofty,strLayer3)
Call Rhino.SurfaceIsocurveDensity(strlofty,-1)
'Call Rhino.DeleteObjects(join)
End If
If ave >= 0.9 Then
Dim scaleMesh3 : scaleMesh3 =
Rhino.ScaleObject(newMesh,meshCent,Array(ave-0.05,ave-0.05,ave-0.05))
Call Rhino.ObjectLayer(scaleMesh3,strLayer)
Dim scaleSrf3 : scaleSrf3 = Rhino.ScaleObject(strPoly,meshCent,Array(ave-
0.05,ave-0.05,ave-0.05))
Call Rhino.ObjectLayer(scaleSrf3,strLayer2)
strlofty =Rhino.AddLoftSrf(Array(strPoly2,scaleSrf3))
Call Rhino.ObjectLayer(strLofty,strLayer3)
Call Rhino.SurfaceIsocurveDensity(strlofty,-1)
'Call Rhino.DeleteObjects(join3)
End If
'Call Rhino.Print("No MATCH")
'Call Rhino.AddTextDot("QVert 0",arrFace(0))
'Call Rhino.AddTextDot("QVert 1",arrFace(1))
'Call Rhino.AddTextDot("QVert 2",arrFace(2))
'Call Rhino.AddTextDot("QVert 3",arrFace(3))
count2 = count2 + 4
End If '///////////////////////////////////////////////////////////////////////////////////////////////////
i = i + 4
count = count + 4
Loop '///////////////////////////////////////////////////////////////////////////////////////////////////
Rhino.EnableRedraw True
End If
Call Rhino.LayerVisible(strLayer,False)
Call Rhino.LayerVisible(strLayer4,False)
Call Rhino.LayerVisible(strMainLayer,False)
Call Rhino.LayerVisible(strLayer7,False)
Rhino.Command "_selcrv"
Rhino.Command "_hide"
'Call Rhino.Print(Ubound(counter))
End Sub
