Grasshopper

algorithmic modeling for Rhino

Iam trying to recreate uto's explode mesh (creates new mesh from every single meshface)

Private Sub RunScript(ByVal meshIn As Mesh, ByVal dirVec As Vector3d, ByVal makeQuads As Object, ByRef triangulated As Object)
Dim meshList As New List(Of Mesh)
Dim meshInQuad As New Mesh
meshInQuad = meshIn
Dim meshDT As New DataTree(Of Point3d)

If makeQuads = True Then
meshInQuad.Faces.ConvertTrianglesToQuads(system.Math.PI, 0.00000001)
End If

Dim meshVerts As New List(Of point3d)(meshInQuad.Vertices.ToPoint3dArray)

For i As Integer = 0 To meshInQuad.Faces.Count - 1 Step 1
Dim newMesh As New mesh

Dim actFVert As New List(Of Integer)(meshInQuad.Faces.GetTopologicalVertices(i))

If actFVert.Count = 3 Then

Dim newF As New meshface

newF = meshInQuad.Faces.item(i)
newMesh.Vertices.Add(meshInQuad.Vertices.item(newF.A))
newMesh.Vertices.Add(meshInQuad.Vertices.item(newF.b))
newMesh.Vertices.Add(meshinquad.vertices.item(newF.c))
newmesh.Faces.AddFace(meshInQuad.Faces.GetFace(i))
Else
Dim newF As New meshface
newF = meshInQuad.Faces.item(i)
newMesh.Vertices.Add(meshInQuad.Vertices.item(newF.A))
newMesh.Vertices.Add(meshInQuad.Vertices.item(newF.b))
newMesh.Vertices.Add(meshinquad.vertices.item(newF.c))
newMesh.Vertices.Add(meshinquad.vertices.item(newF.d))
newmesh.Faces.AddFace(meshInQuad.Faces.GetFace(i))

End If
meshList.Add(newMesh)
Next

Why output is a complete mess ? I tried millions of combinations with get, set, copy vertices as point, integer etc...

Views: 975

Replies to This Discussion

Didn't test this code:

Dim mesh As Mesh = GetMeshFromSomewhere()
Dim meshList As New List(Of Mesh)
For i As Int32 = 0 To mesh.Faces.Count - 1
  Dim face As MeshFace = mesh.Faces(i)
  Dim newMesh As New Mesh()
  newMesh.Vertices.Add(mesh.Vertices(face.A))
  newMesh.Vertices.Add(mesh.Vertices(face.B))
  newMesh.Vertices.Add(mesh.Vertices(face.C))

  If (face.IsTriangle) Then
    newMesh.Faces.AddFace(0, 1, 2)
  Else
    newMesh.Vertices.Add(mesh.Vertices(face.D))
    newMesh.Faces.AddFace(0, 1, 2, 3)
  End If
  meshList.Add(newMesh)
Next

--

David Rutten

david@mcneel.com

Poprad, Slovakia

What kind of sorcery is this ?! I tried gazillions of ways of doing that, where I make a mistake ?

newMesh.Vertices.Add(mesh.Vertices.item(face.B))

vs. 

newMesh.Vertices.Add(mesh.Vertices(face.B))

How  exactly this works, and why my script creates mess? What mesh.vertices.item(face.b) returns ?

Here's the grasshopperized version:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service