1
$\begingroup$

I have an obj file that describes an isosurface of a physical variable. I ran into the problem that my grid is so large that the file size becomes very bloated by undefined entries ("v NaN NaN NaN"). I was wondering if there is a tool that can help adjust the obj file so that these entries are removed and the indices ("f .. .. ..") correctly updated. thanks!

$\endgroup$
2

1 Answer 1

1
$\begingroup$

The file is pretty huge, so writing a custom python script would probably be tiresome and slow performancewise (and has not really something to do with Blender and may be better asked on StackOverflow). But lets go with a Blender solution:

  • import the .obj file
  • export the object edenhofer0.100000 as .ply file
  • import the .ply file again

Now all $(Nan, Nan, Nan)$ have been converted to $(0,0,0)$ vectors. Select the object, go to vertex edit mode, select all vertices at the origin and delete them. This gives a whopping 601476 deleted vertices.

Of course this solution is only applicable if you can use $(0,0,0)$ for that cleanup. On the bright side cleaning the file is done in around a minute and all the re-indexing is done by Blender.

(Edit: replacing all $Nan$ with $0$ in a text editor should be enough. If the text editor starts to tumble because the file is too big, the .ply way is a nice alternative as it converts the $Nan$ values automatically.)

$\endgroup$
4
  • $\begingroup$ Thank you, this is a fantastic suggestions. Thanks to your tip, I ended up with a slightly modified solution because the route via .ply files did not work for me. I simply replaced all NaN in the obj files with 0 (I know in my case there should be nothing physically meaningful at zero), then opened this new obj file with blender, went to edit mode, merged by distance, and deleted any weird leftover vertices. And that was is, no more NaNs and an intact file! Thanks! $\endgroup$ Sep 5, 2023 at 18:01
  • $\begingroup$ Great! Out of curiosity, why did the ply way not work? I had trouble replacing all Nans to zeroes in a text editor because the file was so big^^ $\endgroup$
    – taiyo
    Sep 5, 2023 at 18:04
  • 1
    $\begingroup$ Blender crashed on my end with the ply files. I simply used sed in bash to replace the values, then it doesn't matter how big the file is (sed -i '' 's/NaN/0.0/g' filename.txt) $\endgroup$ Sep 6, 2023 at 10:40
  • $\begingroup$ Hmm, no idea why it crashes. Using bash is also a nice way of converting the values. But I'll leave the .ply way in the answer as it only relies on Blender and this is a Blender site. $\endgroup$
    – taiyo
    Sep 6, 2023 at 11:11

You must log in to answer this question.

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