*# // begin block of Spring
*Set Var ioSpring=-1
*Set Var LastCurrentType=-1
*Set Var CurrentType=0
*Set Var index=InitElemSpringID
*Intformat "%10i"
*#
*loop Intervals
*#
*Set Cond Spring_for_Line *elems   *CanRepeat
*#
*If(CondNumEntities(Int)>0)
*WarningBox Info: You can only define Springs in the first Interval
// selection has *CondNumEntities entities
*loop elems *OnlyInCond
*# vyhozeno issue 1347
*#If(ElemsNnode!=20 || ElemsNnode!=8)
*#WarningBox Info: Elemental springs are programmed experimentaly For Linear or Quadratic brick(Shell). Check it For other element types.
*#EndIf
*#
*If(strcmp(Cond(Geometrical_Non-Linearity),"LINEAR")==0)
*# ElemsNnodeFace je 1 a proto ...
*Set Var CurrentType=1
*#// *\*WarningBox Warning: Element type1 *Cond(Geometrical_Non-Linearity), *AddingNonLinElemID
*Else
*Set Var CurrentType=Operation(AddingNonLinElemID+1)
*#// *\*WarningBox Warning: Element type2 *Cond(Geometrical_Non-Linearity), *AddingNonLinElemID
*EndIf
*#
*#include ..\include.src.bas\SpringNumbering.bas
*#

*If(CurrentType==1)
	ELEMENT TYPE ID *index /** 1**/ NAME "Element type #*CurrentType for Linear Material" TYPE "CCLineSpring" LINEAR ;
*ElseIf(CurrentType==31)
	ELEMENT TYPE ID *index /** 31**/ NAME "Element type #*CurrentType for NonLin Material" TYPE "CCLineSpring" NONLINEAR ;
*EndIf
  ;
*If(strcmp(Cond(Spring_Non-Linearity),"NONLINEAR")==0)
FUNCTION ID *index
  NAME "Function for Spring condition"
  TYPE "CCMultiLinearFunction" REMOVE_ALL 
  xvalues *\
*for(i=2;i<=Cond(F_of_Eps_diagram,Int);i=i+2)
  *Cond(F_of_Eps_diagram,*i) *\
*End

  yvalues *\
*for(i=1;i<=Cond(F_of_Eps_diagram,Int);i=i+2)
  *Cond(F_of_Eps_diagram,*i) *\
*End
 ;
*EndIf
*#

MATERIAL ID *index
  NAME "Material Spring as Cond"
  TYPE "*Cond(Material_Prototype)"
*If(strcmp(Cond(Spring_Non-Linearity),"LINEAR")==0)
  K *Cond(Initial_stiffness-K)
*Else
  FUNCTION *index
*EndIf
 ;
 GEOMETRY ID *index *\
NAME "Geometry for Spring" TYPE
*If(strcmp(Cond(Coordinate_System),"GLOBAL")==0)
    "Spring" thickness *Cond(Spring_Area) direction *Cond(Dir_X,Real) *Cond(Dir_Y,Real) *\
*if(ndime==3)
    *Cond(Dir_Z,Real)
*EndIf
*Else
*include ..\include.src.bas\NormalVector_ElementalLine.bas
*Set Var dln=Operation(sqrt(nx*nx+ny*ny))
*#
*# *ElemsNnode x1 *ElemsNnodeFace x2
*Set Var length=Cond(Spring_Length,Real)
    "Spring" direction *Operation(nx/dln*length) *Operation(ny/dln*length) *\
*#if(ndime==3)
*#    *Operation(nz/dln*length)
*#EndIf
*EndIf

*# // center of face of element *elemsnum
*# JOINT COORDINATES
*# *Set Var findef=index
*#   *findex *fx *fy *fz

 ELEMENT GROUP ID *index TYPE *index /** *ElemsMatProp(0) - *CurrentType **/ MATERIAL *index GEOMETRY  *index
 ELEMENT INCIDENCES
*# // *ElemsMatProp(0) *ElemsMatProp(1)
/** original 3d element id *elemsnum **/ 
*include ..\include.src.bas\Spring_Element_Conectivity.bas

*#Set Var ioSpring=Operation(ioSpring+1)
*Set Var LastCurrentType=CurrentType
*#
*End elems
*EndIf
*#
// *\
*break
*End interval
