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. Python API
  4. AttributeError: 'NoneType' object has no attribute 'Results'

AttributeError: 'NoneType' object has no attribute 'Results'

Scheduled Pinned Locked Moved Python API
2 Posts 2 Posters 121 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.
  • L Offline
    L Offline
    lucky_lin
    wrote last edited by Sylvain
    #1

    da8373d6-5f15-4ffb-be6f-fd806be28621-image.png
    The simulation suddenly encountered this error, even though the same code was used previously without any issues.

    import numpy
    import s4l_v1.analysis as analysis
    import s4l_v1.document as document
    import s4l_v1.model as model
    import s4l_v1.units as units
    from s4l_v1 import ReleaseVersion
    from s4l_v1 import Unit
    
    try:
        # Define the version to use for default values
        ReleaseVersion.set_active(ReleaseVersion.version8_2)
        
        # Creating the analysis pipeline
        # Adding a new SimulationExtractor
        simulation = document.AllSimulations["0_17_35_29"]
        simulation_extractor = simulation.Results()
    
        # Adding a new EmSensorExtractor
        em_sensor_extractor = simulation_extractor["Overall Field"]
        em_sensor_extractor.FrequencySettings.ExtractedFrequency = u"All"
        document.AllAlgorithms.Add(em_sensor_extractor)
    
        # Adding a new CurrentExtractor
        inputs = [em_sensor_extractor.Outputs["EM Potential(x,y,z,f0)"], em_sensor_extractor.Outputs["J(x,y,z,f0)"]]
        current_extractor = analysis.extractors.CurrentExtractor(inputs=inputs)
        current_extractor.IsoSurfacePerCentThreshold = 30.0
        current_extractor.UpdateAttributes()
        document.AllAlgorithms.Add(current_extractor)
    
    except Exception as exc:
        import traceback
        traceback.print_exc()
        # Reset active version to default
        ReleaseVersion.reset()
        raise(exc)
    
    1 Reply Last reply
    0
    • SylvainS Offline
      SylvainS Offline
      Sylvain
      ZMT
      wrote last edited by
      #2

      Hi,
      You would get that error if there was no simulation named "0_17_35_29" in the currently opened document. Maybe you should check what simulations you have in your project and if you do have a simulation with that name?

      One way to list all simulation names via python is to run something like:

      for s in document.AllSimulations:
         print(s.Name)
      
      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