Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. CAD Modeling
  4. Importing polylines from text file

Importing polylines from text file

Scheduled Pinned Locked Moved Unsolved CAD Modeling
2 Posts 2 Posters 473 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SylvainS Offline
    SylvainS Offline
    Sylvain
    ZMT
    wrote on last edited by
    #1

    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,zn
    

    I know this can be done using the Python API, but I was trying to find a way to do it via the GUI.

    1 Reply Last reply
    0
    • brynB Offline
      brynB Offline
      bryn
      ZMT
      wrote on last edited by bryn
      #2

      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()
      
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Search