*# // begin block of Spring
*Set Var ioSpring=0
*Set Var nSpring=0
*Set Var LastNumofMultilinear=-1
*Set Var LastInitial_stiffness_K=-1
*Set Var LastDirX=-1
*Set Var LastDirY=-1
*Set Var LastDirZ=-1
*Set Var LastCurrentType=-1
*Set Var CurrentType=0
*Intformat "%10i"

*loop Intervals
*Set Cond Spring_for_Point   *nodes   *CanRepeat
*#
*If(CondNumEntities(Int)>0)
*WarningBox Info: You can only define Springs in the first Interval
// selection has *CondNumEntities entities
*loop nodes *OnlyInCond
*#
*Set Var NowSumofMultilinear = 0
*for(i=1;i<=Cond(F_of_Eps_diagram,Int);i=i+1)
*Set Var number = Cond(F_of_Eps_diagram,real,*i) 
*Set Var number = Operation(number*i*10*1.34876)
*# 1.34876 is only ZJ constant
*Set Var NowSumofMultilinear = Operation(NowSumofMultilinear+number)  
*End
*#NowSumofMultilinear = *NowSumofMultilinear (LastNumofMultilinear = *LastNumofMultilinear)
*#
*If( LastNumofMultilinear!=NowSumofMultilinear || LastInitial_stiffness_K!=Cond(Initial_stiffness-K,Real) || LastDirX!=Cond(Dir_X,Real) || LastDirY!=Cond(Dir_Y,Real) || LastDirZ!=Cond(Dir_Z,Real) || CurrentType!=LastCurrentType )
*If(strcmp(Cond(Geometrical_Non-Linearity),"LINEAR")==0)
*# ElemsNnode 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

*Set Var ioSpring=Operation(ioSpring+1)
  ;
*If(strcmp(Cond(Spring_Non-Linearity),"NONLINEAR")==0)
FUNCTION ID *Operation(ioSpring*IncrSpringID+NodesNum)
  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 *Operation(ioSpring*IncrSpringID+NodesNum)
  NAME "Material Spring as Cond"
  TYPE "*Cond(Material_Prototype)"
*If(strcmp(Cond(Spring_Non-Linearity),"LINEAR")==0)
  	K *Cond(Initial_stiffness-K)
*Else
  FUNCTION *Operation(ioSpring*IncrSpringID+NodesNum)
*EndIf
 ;
 GEOMETRY ID *Operation(ioSpring*IncrSpringID+NodesNum) NAME "Geometry for Spring" TYPE
    "Spring" area *Cond(Spring_Area) direction *Cond(Dir_X,Real) *Cond(Dir_Y,Real) *\
*if(ndime==3)
    *Cond(Dir_Z,Real)
*EndIf

*Set Var index=Operation(ioSpring*IncrSpringID+CurrentType)

*If(CurrentType==1)
	ELEMENT TYPE ID *index /** 1**/ NAME "Element type #*CurrentType for Linear Material" TYPE "CCSpring" LINEAR ; // "CCLineSpring" LINEAR ; // "CCPlaneSpring" LINEAR ;
*ElseIf(CurrentType==31)
	ELEMENT TYPE ID *index /** 31**/ NAME "Element type #*CurrentType for NonLin Material" TYPE "CCSpring" NONLINEAR ; // "CCLineSpring" NONLINEAR ; // "CCPlaneSpring" NONLINEAR ;
*EndIf

 ELEMENT GROUP ID *index TYPE *index /** *CurrentType **/ MATERIAL *Operation(ioSpring*IncrSpringID+NodesNum) GEOMETRY  *Operation(ioSpring*IncrSpringID+NodesNum)
 ELEMENT INCIDENCES
*# // *ElemsMatProp(0) *ElemsMatProp(1)
*EndIf
  *Operation(InitSpringID+nSpring+NodesNum) *NodesNum
*# 
*Set Var nSpring=Operation(nSpring+1)
*#Set Var LastNum_of_Multilinear=Cond(F_of_Eps_diagram,Int)
*Set Var LastNumofMultilinear = NowSumofMultilinear

*Set Var LastInitial_stiffness_K=Cond(Initial_stIffness-K,Real)
*Set Var LastDirX=Cond(Dir_X,Real)
*Set Var LastDirY=Cond(Dir_Y,Real)
*Set Var LastDirZ=Cond(Dir_Z,Real)
*Set Var LastCurrentType=CurrentType
*End nodes
// *\
*EndIf
*break
*End Intervals
*# ----------------------------------------
*# Set MAX_REF_ID NODES_SMART_IDS_MAP *Operation((npoin/1000+1)*1000)
