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. Creating coils via Python

Creating coils via Python

Scheduled Pinned Locked Moved Python API
pythoncoils
1 Posts 1 Posters 500 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 Sylvain
    #1

    The GenericToolkit module, available from the Python API of Sim4Life, interfaces with most of the templating tools of the GUI.
    One can for example use it to interface with the Coil Template tool to generate all sorts of coils, as in the example below:

    import GenericToolkit
    import s4l_v1.document as doc
    
    
    ## Solenoid, circular
    newcoil = GenericToolkit.Create('Coil')
    
    newcoil.Parameters.Geometry.CoilGeometry.Spatial.Value = 1  # {0: u'Flat', 1: u'Solenoid'}
    newcoil.Parameters.Geometry.CoilGeometry.Shape.Value = 1    # {0: u'Rectangular', 1: u'Circular'}
    newcoil.Parameters.Geometry.CoilGeometry.Figure.Value = 0   # {0: u'Helix', 1: u'Parallel Circles'}
    # newcoil.Parameters.Geometry.CoilGeometry.Figure.Values    # list all available values (in the console)
    
    newcoil.Parameters.Geometry.CoilProperties.Radius.Value = 50  
    
    newcoil.Parameters.Geometry.Layers.NumLayers.Value = 6
    newcoil.Parameters.Geometry.Layers.Thickness.Value = 12
    
    newcoil.EvaluateParameters()
    
    
    
    ## Solenoid, square
    newcoil = GenericToolkit.Create('Coil')
    
    newcoil.Parameters.Geometry.CoilGeometry.Spatial.Value = 1  # {0: u'Flat', 1: u'Solenoid'}
    newcoil.Parameters.Geometry.CoilGeometry.Shape.Value = 0    # {0: u'Rectangular', 1: u'Circular'}
    newcoil.Parameters.Geometry.CoilGeometry.Figure.Value = 0   # {0: u'Helix', 1: u'Parallel Circles'}
    
    newcoil.Parameters.Geometry.CoilProperties.Width.Value = 50  
    newcoil.Parameters.Geometry.CoilProperties.Length.Value = 70  
    
    newcoil.Parameters.Geometry.Layers.NumLayers.Value = 3
    newcoil.Parameters.Geometry.Layers.Thickness.Value = 4
    
    newcoil.EvaluateParameters()
    
    
    ## Flat, circular
    newcoil = GenericToolkit.Create('Coil')
    
    newcoil.Parameters.Geometry.CoilGeometry.Spatial.Value = 0  # {0: u'Flat', 1: u'Solenoid'}
    newcoil.Parameters.Geometry.CoilGeometry.Shape.Value = 1    # {0: u'Rectangular', 1: u'Circular'}
    newcoil.Parameters.Geometry.CoilGeometry.Figure.Value = 0   # {0: u'Helix', 1: u'Parallel Circles'}
    
    newcoil.Parameters.Geometry.CoilProperties.NumTurns.Value = 10 
    newcoil.Parameters.Geometry.CoilProperties.InnerRadius.Value = 25  
    newcoil.Parameters.Geometry.CoilProperties.OuterRadius.Value = 45  
    
    newcoil.Parameters.Geometry.Layers.NumLayers.Value = 1
    
    newcoil.EvaluateParameters()
    
    
    # Print all available properties in the Console
    print newcoil.Parameters.DumpTree()
    
    1 Reply Last reply
    1
    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