Navigation: Scripting Reference Manual > Functions & Subroutines > AddCoil

 

AddCoil

 

Contact Us: fredsupport@photonengr.com

 

Description

Adds a Coil surface type to the FRED document parameterized by its helix radius, cross section radius, pitch and turn count.

 

Syntax

cNode = AddCoil( ent, hRad, cRad, pitch, turns )

 

Parameters

cNode ( Long )

Returned node number of the Coil surface added to the document.

 

ent As T_ENTITY

Structure containing the basic information about the coil surface being added (name, description, parent, etc.)

 

hRad As Double

Major radius of the coil.

 

cRad As Double

Minor radius of the cross section (cannot be greater than half the pitch).

 

pitch As Double

Distance between neighbor coil turns.

 

turns As Double

Number of coil turns (can be non-integer).

 

 

Remarks

 

 

Example

The following example code creates a custom element node, adds a coil surface to the custom element, sizes the coil surface trimming volume appropriately and adjusts the surface draw mode.

 

          Dim ent As T_ENTITY

          Dim tVol As T_TRIMVOLUME

          Dim sVis As T_SURFVISUALIZE

          Dim hRad As Double, cRad As Double, pitch As Double, turns As Double

          Dim eNode As Long, cNode As Long

 

          'set the T_ENTITY information for the custom element

          InitEntity ent

          ent.name = "CoilCustomElement"

          ent.Description = "Parent node of the coil surface"

 

          'add a custom element to the document that will parent the coil surface

          eNode = AddCustomElement( ent )

 

          'set the T_ENTITY information for the coil surface

          InitEntity ent

          ent.name = "Scripted Coil"

          ent.Description = "Coil surface added through scripting"

          ent.parent = eNode

 

          'specify coil and add the coil to the document

          hRad = 0.5

          cRad = 0.124

          pitch = 0.25

          turns = 4

          cNode = AddCoil( ent, hRad, cRad, pitch, turns )

 

          'modify the coil's trim volume to be an appropriate size

          Dim zMin As Double, zMax As Double

          GetTrimVolume cNode, tVol

          zMin = - cRad

          zMax = pitch*turns + cRad

          tVol.zSemiApe = (zMax - zMin)/2

          tVol.zCenter = tVol.zSemiApe + zMin

          tVol.xSemiApe = hRad + cRad + 0.01

          tVol.ySemiApe = tVol.xSemiApe

          SetTrimVolume cNode, tVol

 

          'draw the surface using smooth shading (for visual appeal)

          GetSurfVisualize cNode, sVis

          sVis.drawMode = "smooth"

          SetSurfVisualize cNode, sVis

 

          'update the document

          Update

 

See Also

Coil Surface

GetCoil Subroutine

SetCoil Subroutine

 

 

 

 

 

Copyright © Photon Engineering, LLC