v3 plugins
v3 vbscript
v2 vbscript
color match
convert curve equichordal
history hide
mesh mapper
open with V4
sel pts on crv

Mesh MappingMesh Mapper

This script applies the UV texture coordinates from a surface to a mesh by evaluating the surface's closest point from the vertices.

A copy of that mesh with the "pulled" UV texture coordinates will be created.You have to assign a texture manually to see the new mapping. The input mesh remains selected, so you can quickly delete or hide it.

This script is ready to be copied into a button:



-_Runscript ( 
Sub MeshMapper()
'© 2005 Jess Maertterer
Dim strMesh, arrVertices, arrFaceVertices, arrNormals
Dim arrTexCoords, arrBox, i, UV(1)
Dim strSurf, arrParam, arrDomU, arrDomV

Rhino.Print "RhinoScript: MeshMapper"
strMesh = Rhino.GetObject ("Select Mesh", 32, true, false)
If isNull(strMesh) Then Exit Sub

strSurf = Rhino.GetObject("Select Surface", 8)
If isNull(strSurf) Then Exit Sub

arrDomU = Rhino.SurfaceDomain(strSurf, 0)
arrDomV = Rhino.SurfaceDomain(strSurf, 1)

arrVertices = Rhino.MeshVertices(strMesh)
arrFaceVertices = Rhino.MeshFaceVertices (strMesh)
arrNormals = Rhino.MeshVertexNormals (strMesh)

Redim arrTexCoords(ubound(arrVertices))

For i = 0 to ubound(arrVertices)
	arrParam = Rhino.SurfaceClosestPoint(strSurf, arrVertices(i))
	UV(0) = (arrParam(0)-arrDomU(0))/(arrDomU(1)-arrDomU(0))
	UV(1) = (arrParam(1)-arrDomV(0))/(arrDomV(1)-arrDomV(0))
	arrTexCoords(i) = UV

If IsNull(arrNormals) then
Rhino.AddMesh arrVertices, arrFaceVertices , , arrTexCoords
Rhino.AddMesh arrVertices, arrFaceVertices , arrNormals, arrTexCoords
End If

Rhino.SelectObject (strMesh)

End Sub

© 3DE < ^ >