0
$\begingroup$

I have created a mesh (.obj) and run several A* searches on it which yields to me a .txt file where each line is:

  • x,y,z
  • x1,y1,z1 ...

I would like to find a way to ideally import these as a single object, showcasing the route my A* search took along the mesh, but haven't found anything that seems to support that such a request is even possible. Am I missing something here?

EDIT: Here are some screenshots to highlight the data I am working with to hopefully make the question clearer.

  • Image1: This is the mesh my process makes (the holes are expected), where the obj consists of the vertices and faces which compose it.

image

  • Image2: After running A*search, this is the type of output I have, where the path is just a list of vertices visited. I am able to index them to the structure that holds their coordinates for the proposed line I want.

image

Shortest path between start and end nodes on mesh found. ['start', 50502, 50504, 49191, 49193, 47885, 46610, 46612, 45361, 44131, 42932, 41745, 41747, 49583, 39442, 38322, 37213, 36176, 35120, 34086, 33055, 32041, 31045, 30068, 29098, 28140, 27195, 26270, 25351, 24602, 23779, 22490, 21352, 20240, 19154, 18098, 17064, 16059, 15082, 14134, 13214, 12536, 12576, 13495, 14441, 15417, 16421, 17454, 18511, 19592, 20704, 21844, 23009, 24176, 24923, 25846, 26775, 27711, 28688, 29658, 30638, 31625, 32633, 33659, 34694, 35744, 36810, 37900, 39020, 40152, 41305, 'end']
  • Image3: This is what I am hoping to accomplish. A line drawn on the mesh from each point to point.

image

$\endgroup$
7
  • $\begingroup$ object as in mesh, or curve, or edge curve or...? $\endgroup$ Dec 6, 2022 at 9:20
  • 2
    $\begingroup$ Would a better title be: 'How do I import a path from a csv file?' ... Also, FYI, the GN Shortest Path node, (which is a Dijkstra search) will let you trace your paths directly, inside Blender. $\endgroup$
    – Robin Betts
    Dec 6, 2022 at 9:34
  • $\begingroup$ I’d like it to be imported and displayed as line segments that I can change the color of for visualization purposes. Since the requirements of my project are that all computation regarding the build and search of the mesh needs to be self contained, I am only using blender/mesh lab for visualization and mesh design measurements. $\endgroup$
    – Thomas
    Dec 6, 2022 at 11:11
  • $\begingroup$ What's a line segment? Curve, edges, polygons? I would recommend a curve, bc. you can easily change thickness and shape. But coloring different segments depending on the csv. might be tricky. But please provide more details and perhaps screenshots. $\endgroup$ Dec 6, 2022 at 11:18
  • $\begingroup$ Added additional detail to make clearer my problem $\endgroup$
    – Thomas
    Dec 7, 2022 at 3:26

1 Answer 1

2
$\begingroup$

version 01 - Shortest Path node

Robin Betts's comment is right - most direct solution could be use Shortest Path node under Geometry Nodes system ... you can get idea here or here. Since your Q is aiming to a different approach I'm not going to go further here.


version 02 - Text file (CSV) - Index of Vertices

You can copy values from your Image2 (I suppose values represents vertex numbers - indices) and place them into text editor. At row 1 type some name (like "short-path" or what ever) and run find/replace operator to change comma with space to enter character, so your text file end up with single value per row. Save as .csv format.

enter image description here

This file you can import into a Blender with Blender Spreadsheet Importer mentioned in version 03.

Now when values are imported as vertex attributes, select your terrain object and use this geometry node tree to distribute vertices at their locations ... (big thanks to @RobinBetts answer again)

enter image description here

At last, to connect vertices into a path ad Realise Instances node and node group seen in last image of version 03. Note: the "B" value is just a limit of vertices to be connected.


version 03 - Text file (CSV) - XYZ

Import CSV data of XYZ as Attribute for Geometry nodes. Each row contains three columns of X Y Z values. For simplicity I used just three vertices. -the first at loc 0, 0, 0, second at 1, 1, 1 etc.

enter image description here

To import CSV data for Geometry Nodes use this great addon Blender Spreadsheet Importer by simonbroggi.

enter image description here

Data are brought into blender as object attributes ...

enter image description here

And set this node tree ...

enter image description here enter image description here

... to generate line add this node group ...

enter image description here enter image description here

Node group seen in image above ... enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .