Importing polylines from text file
-
In Sim4Life GUI-->Import, there is a .txt file format called "outline file files".
Can this one be used to import a polyline?I have polylines defined like a list of points:
x1,y1,z1 x2,y2,y2 .... xn,yn,znI know this can be done using the Python API, but I was trying to find a way to do it via the GUI.
-
You would have to define the polylines in a supported file format, e.g. VTK.
To create such a file from Python, you could do something like this:
import vtk # define points x1,y1,z1, etc. # add the actual points points = vtk.vtkPoints() points.InsertNextPoint(x1,y1,z1) points.InsertNextPoint(x2,y2,z2) points.InsertNextPoint(x3,y3,z3) # define the lines lines = vtk.vtkCellArray() lines.InsertNextCell(3) # next line is composed of 3 vertices lines.InsertCellPoint(0) # vertex 1 lines.InsertCellPoint(1) # vertex 2 lines.InsertCellPoint(2) # vertex 3 # assemble as surface mesh mesh = vtk.vtkPolyData() mesh.SetPoints(points) mesh.SetLines(lines) # write to file, supported by Sim4Life, Paraview, etc. writer = vtk.vtkDataSetWriter() writer.SetInputData(mesh) writer.SetFileName(r"E:\temp\Foo.vtk") writer.Write()
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login