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