# Mesh to Indexed Point, and Indexed Line lists?

Hi…,

sorry I am a Grasshopper dummy.

Is there a GH-program to get an indexed point, and indexed line list from a mesh (without double points and lines), like this:

``````List of Point-Arrays [Point Index, x, y, z]
===============================================

[0, 14.5, 17.5, 5.5],
[1, 12.5, 3.0, 7.5],
[2, 17.5, 1.5, 99.5],
[3, 37.5, 21.5, 9.5],
...

List of Line-Arrays [Line Index, Start-Point Index, End-Point Index]
===================================================================================

[0, 0, 1],
[1, 0, 2],
[2, 0, 3],
[3, 1, 2],
[4, 1, 3],
...
``````

Thanks

Michael

1 Like

Network from Lines by Heteroptera for example

1 Like

In case that you are familiar with coding (or you have future plans to do that):

7 out of the 9 possible Mesh connectivity Trees (related with topology vertices (TV) - Note: not vertices, topology edges (TE) and faces (F) => 3*3 = 9 combos) are directly doable via SDK Methods (and the rest 2 are not nuclear science) : meaning that is very easy to do what you want (or any imaginable TV, TE, F info combo [as List in a Tree or a custom class properties etc etc]).

Notify if you need a C# example on that.

I am familiar with JavaScript, a little with Python, and dragging some components in GH.

I didn’t want to spend too much time by digging in new languages or testing unknown GH components.

Thanks

Michael

Hi scripters,

I’ve written now a python script to get my lists in JSON format:

``````mesh: {
point: [
{ id:   0, x:   -6.9694, y:    9.2147, z:    0.0000 },
{ id:   1, x:   -7.3193, y:    2.6245, z:    0.0000 },
{ id:   2, x:   -0.6124, y:    2.9161, z:    0.0000 },
{ id:   3, x:    1.0206, y:    8.8065, z:    0.0000 },
{ id:   4, x:    4.5199, y:    1.3414, z:    0.0000 },
{ id:   5, x:    6.9694, y:    7.6984, z:    0.0000 },
{ id:   6, x:    5.4530, y:   12.9473, z:    0.0000 }
],
line: [
{ id:   0, a:   0, b:   1 },
{ id:   1, a:   1, b:   2 },
{ id:   2, a:   2, b:   3 },
{ id:   3, a:   3, b:   0 },
{ id:   4, a:   2, b:   4 },
{ id:   5, a:   4, b:   5 },
{ id:   6, a:   5, b:   3 },
{ id:   7, a:   6, b:   3 },
{ id:   8, a:   5, b:   6 }
]
}
``````

It converts all quads and tris of a mesh to point and line lists without double entries. Here is the python script, if someone needs it: mesh_to_point_and_line_lists.py (3.3 KB)

Thanks

Michael

Hi…,

if someone is interested, I have written another version which writes normals, vertices, and faces of a mesh to JSON: 20200416_mesh_normals_vertices_faces_to_JSON.py (3.7 KB)

The JSON looks like this:

``````mesh: {
normals: [
{ id:   0, x:   -0.2173, y:    0.0345, z:    0.9755 },
{ id:   1, x:    0.0000, y:   -0.0000, z:    1.0000 },
{ id:   2, x:   -0.0497, y:   -0.2668, z:    0.9625 }
],
vertices: [
{ id:   0, x:   -7.3193, y:    2.6245, z:   -1.6390 },
{ id:   1, x:   -0.6124, y:    2.9161, z:    0.0000 },
{ id:   2, x:    1.0206, y:    8.8065, z:    0.0000 },
{ id:   3, x:   -6.9694, y:    9.2147, z:   -1.6390 },
{ id:   4, x:    4.5199, y:    1.3414, z:    0.0000 },
{ id:   5, x:    6.9694, y:    7.6984, z:    0.0000 },
{ id:   6, x:    5.4530, y:   12.9473, z:    1.3766 }
],
faces: [
{ id:   0, normal:   0, v0:   0, v1:   1, v2:   2, v3:   3 },
{ id:   1, normal:   1, v0:   1, v1:   4, v2:   5, v3:   2 },
{ id:   2, normal:   2, v0:   2, v1:   5, v2:   6 }
]
}
``````

Take care

Michael