algorithmic modeling for Rhino
You provide some points, it'll output a mesh which triangulates those points.
hi david, i provide one point and one mesh to the script. i try to explote the mesh in points and add the new point to the mesh. in the script output say '1. Solution exception:Object reference not set to an instance of an object.'
Dim m As Mesh
Dim Punto As Rhino.Geometry.Point3d
If (Not DA.GetData(0, m)) Then Return
If (Not DA.GetData(1, Punto)) Then Return
Dim caras As Rhino.Geometry.Collections.MeshFaceList
caras = m.Faces
Dim vert As Rhino.Geometry.Collections.MeshVertexList
vert = m.Vertices
Dim i As Integer
Dim pts As New List(Of Point3d)
Dim cara As New MeshFace
For i = 0 To caras.Count - 1 Step 1
pts.Add(New Point3d(vert(caras(i).A)))
pts.Add(New Point3d(vert(caras(i).B)))
pts.Add(New Point3d(vert(caras(i).C)))
If caras(i).IsQuad Then pts.Add(New Point3d(vert(caras(i).D)))
Next
pts.Add(Punto)
Dim N2L As New Grasshopper.Kernel.Geometry.Node2List(pts)
Dim DF As List(Of Grasshopper.Kernel.Geometry.Delaunay.Face) = Grasshopper.Kernel.Geometry.Delaunay.Solver.Solve_Faces(N2L, 1)
Dim DFace As Grasshopper.Kernel.Geometry.Delaunay.FaceEx
Dim Faces As List(Of MeshFace)
For Each DFace In DF
Dim MF As New MeshFace(DFace.A, DFace.B, DFace.C)
Faces.Add(MF)
Next
Dim mesh2 As New Mesh
mesh2.Vertices.AddVertices(pts)
mesh2.Faces.AddFaces(Faces)
DA.SetData(0, mesh2)
this is the code...
thx for reply
I am not sure if it's the precise problem creating your error, but you will definitely be adding duplicates for all vertices that are shared by your initial mesh.
The Delaunay algorithm cannot be used to insert points into meshes, at best you can extract all your mesh vertices, add one to the list and then create a new mesh from all the points. There will be no guarantee that the points will be connected in the same way, unless the input mesh was already an unambiguous valid delaunay triangulation. And even then the order of faces and edges may be wildly different.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by