I want to implement a simplified version of what I have suggested here to import some vertices from an OpenFOAM blockMeshDict
file and then visualize them with FreeCAD.
the part of the file I'm interested in is a list of tuples (xi yi zi)
s of floats, between parentheses after the vertices
keyword. the file looks like this:
vertices
(
(1 2 3)
(3 4 5)
...
)
I'm able to read the file from the same folder as the python script with:
import os
os.chdir(os.path.dirname(__file__))
with open("blockMeshDict", "r") as f:
s=f.read()
But then when I try to extract the content between the parentheses after the vertices
with:
import re
r1=re.search(r'vertices\n\((.*?)\)', s)
print r1.group(1)
I get the error:
type 'exceptions.IndexError: no such group
and I don't know how to solve it. What I want to have in the end is a list of tuples like [(x1,y1,z1),(x2,y2,z2)...]
I would appreciate it if you could help me know how I can implement this in Python 2.7.
P.S. A summary of this effort can be found in this GitHub Gist