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. Extract Points outputs only one vertex. Possible bug?

Extract Points outputs only one vertex. Possible bug?

Scheduled Pinned Locked Moved CAD Modeling
4 Posts 2 Posters 465 Views 2 Watching
  • 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.
  • J Offline
    J Offline
    jseo977
    wrote on last edited by
    #1

    Hello,

    When I try to extract the set of points that made a sketch (eg. through a loop made from a set of spline points) that has been moved and scaled, the output of Extract -> Extract Points, I only get a single vertex.

    Why could this be?
    This behaviour also happens in the Python API.

    Any help at all is greatly appreciated.Screenshot 2024-04-23 at 8.34.49 PM.png Screenshot 2024-04-23 at 8.35.11 PM.png

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brown
      ZMT
      wrote on last edited by
      #2

      This behavior is by design for splines in Sim4Life. To extract points along a spline via the GUI, select the spline, then go to Wire Tools > To Polyline. This will allow you to specify a Faceting parameters that will determine how many points can be extracted.

      To extract points via the Python API, you can manually extract the points used to define the initial spline, or you can resample the spline:

      # -*- coding: utf-8 -*-
      
      import s4l_v1.model as model
      import XCoreModeling
      
      
      entity = model.AllEntities()['Spline Name']
      
      # Get exact points making up spline
      points_exact = []
      for p in entity.Parameters[0]:
      	points_exact.append(p.Value)
      
      # Sample spline
      sample_interval = 100
      wires = XCoreModeling.GetWires(entity)
      curve = wires[0].GetGeometry()
      curve.Transform(entity.Transform)
      interval = curve.ParameterRange
      length = XCoreModeling.MeasureLength([entity])
      num_samples = int(length / sample_interval)
      param_delta = (interval.End - interval.Start) / num_samples
      
      points_sampled = []
      for i in range(num_samples):
      	points_sampled.append(curve.Eval(interval.Start + i * param_delta))
      
      1 Reply Last reply
      1
      • J Offline
        J Offline
        jseo977
        wrote on last edited by
        #3

        For some reason the first method doesn't appear to work (entity.Parameters is NoneType?)
        The second method seems to work though.
        Thank you so much.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          brown
          ZMT
          wrote on last edited by
          #4

          The first method might not be working if your spline doesn't have a parametrization. If you click on the spline in the Model tree and don't see a list of points in the Controller window, then the information is no longer available and you'll have to stick to the second method.

          1 Reply Last reply
          2
          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