*# result is set in variable groupID and CurrentType
*#
*# ----------------- pred -------------
*# ElemConstrActiv = *ElemConstrActiv
*# ------------------------------------
*#
*# Set Var i2index=0
*If(ElemsMat<=0)
// Element *ElemsNum has not assigned Material.
*#
ElemsNum    *ElemsNum *ElemsConec
ElemsMat    *ElemsMat
ElemsNnode  *ElemsNnode
ElemsType   *ElemsType
CurrentType *CurrentType
*#
*tcl(TK_Signal *ElemsNum)
*MessageBox error: Element *ElemsNum has not assigned Material. Please see .dat file.
*EndIf
*#
*Set Var beammaterial=strcmp(ElemsMatProp(Material_Prototype),"CCBeam3DMaterial")
*Set Var shellmaterial=strcmp(ElemsMatProp(Material_Prototype),"CCShellMaterial")
*#
*If(shellmaterial==0)
*Set Var nshells=Operation(nshells+1)
*ElseIf(beammaterial==0)
*Set Var nbeam=Operation(nbeam+1)
*EndIf
*#
*# only for Temperature problemtype and derivations
*If(strcmp(ElemsMatProp(Material_Prototype),"CCModelBaXi94")==0 || strcmp(ElemsMatProp(Material_Prototype),"CCSandwicKubina")==0)
*Set Var MaterialType=1
*EndIf
*#
*Set Var CurrentType=-1
*Set Var groupID=-1
*#
*# begin test of combination of Element Type
*#
*If(ElemsType!=1 && strcmp(ElemsMatProp(Material_Prototype),"CCReinforcement")==0)
*MessageBox error: Material "CCReinforcement" is permited only For 1D Elements
*#
*ElseIf(ElemsType!=1 && strcmp(ElemsMatProp(Material_Prototype),"CC1DElastIsotropic")==0) 
*MessageBox error: Material "CC1DElastIsotropic" is permited only For 1D Elements
*#
*ElseIf(ElemsType!=1 && strcmp(ElemsMatProp(Material_Prototype),"CCSteelDRC")==0)       
*MessageBox error: Material "CCSteelDRC" is permited only For 1D Elements
*#
*ElseIf(ndime==2 && strcmp(ElemsMatProp(Material_Prototype),"CC3DInterface")==0)
*MessageBox error: Material "CC3DInterface" is permited only in 3D
*#
*ElseIf(ndime==3 && strcmp(ElemsMatProp(Material_Prototype),"CC2DInterface")==0)
*MessageBox error: Material "CC2DInterface" is permited only in 2D
*#
*ElseIf(ndime==2 && (shellmaterial==0 || beammaterial==0))
*MessageBox error: Material "CCShellMaterial" or "CCBeam3DMaterial" is permited only for 3D. If you have only one 1Dbeam or 2DShell, please move it from z=0
*EndIf
*#
*If(strcmp(ElemsMatProp(Material_Prototype),"CC3DInterface")==0 && (ElemsType==1 || ElemsType==2 || ElemsType==3 || ElemsType==4 || ElemsType==7))
*MessageBox error: Material "CC3DInterface" is not permited for Element Type: Line, Triangle, Quad, Tetrahedron, Point
*EndIf
*If(strcmp(ElemsMatProp(Material_Prototype),"CC2DInterface")==0 && (ElemsType==1 || ElemsType==2 || ElemsType==4 || ElemsType==5 || ElemsType==6 || ElemsType==7))
*MessageBox error: Material "CC2DInterface" is not permited for Element Type: Line, Triangle, Hexahedron, Tetrahedron, Prism, Point
*EndIf
*If((shellmaterial==0 || beammaterial==0) && (ElemsType!=5 && ElemsType!=6 && ElemsType!=3 && ElemsType!=2 && ElemsType!=1))
// *ElemsType
*MessageBox error: Materials "CCShellMaterial" and "CCBeam3DMaterial" are permited only for Element 3D(Hexahedron, Prism) and 2D (Quad and Triangle)
*EndIf
*# ////// zjisteni kvadratic 
*Set Var MaterialQuadratic=ElemsMatProp(Non-Quadratic_Element,Int)
*Set Var JeQuadratic = IsQuadratic(Int)
*If(MaterialQuadratic==1)
*Set Var JeQuadratic = 0
*EndIf
*# ////// zjisteni kvadratic end
*If((shellmaterial==0 || beammaterial==0) && JeQuadratic!=1 )
*If(strcmp(ElemsMatProp(Element_Type),"CCIsoShellQuad<xxxx>")!=0 && strcmp(ElemsMatProp(Element_Type),"CCIsoShellBrick<xxxxxxxx>")!=0 && strcmp(ElemsMatProp(Element_Type),"CCIsoShellWedge<xxxxxx>")!=0 && strcmp(ElemsMatProp(Element_Type),"CCIsoShellTriangle<xxx>")!=0)
*MessageBox error: Material "CCShell/CCBeam" is permited only for Quadratic element. Go to menu Mesh -> Quadratic type -> Quadratic. Or change the material element type to linear.
*EndIf
*EndIf
*#
*# End of test of combination of Element Type
*#
*If(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"LINEAR")==0 && (strcmp(ElemsMatProp(Material_Prototype),"CC3DInterface")==0 || strcmp(ElemsMatProp(Material_Prototype),"CC2DInterface")==0))
*#Set Var CurrentType=Operation(ElemsNnode+AddingGapElemID)
*Set Var CurrentType=Operation(ElemsType+AddingGapElemID)
*#
*ElseIf(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"NONLINEAR")==0 && (strcmp(ElemsMatProp(Material_Prototype),"CC3DInterface")==0 || strcmp(ElemsMatProp(Material_Prototype),"CC2DInterface")==0))
*#Set Var CurrentType=Operation(ElemsNnode+AddingGapElemID+AddingNonLinElemID)
*Set Var CurrentType=Operation(ElemsType+AddingGapElemID+AddingNonLinElemID)
*#
*ElseIf(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"LINEAR")==0 && (shellmaterial==0 || beammaterial==0))
*Set Var CurrentType=Operation(16*1)
*#
*ElseIf(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"NONLINEAR")==0 && (shellmaterial==0 || beammaterial==0))
*Set Var CurrentType=Operation(16+AddingNonLinElemID)
*#
*ElseIf(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"LINEAR")==0 && strcmp(ElemsMatProp(Material_Prototype),"CC3DInterface")!=0 && strcmp(ElemsMatProp(Material_Prototype),"CC2DInterface")!=0)
*#Set Var CurrentType=Operation(ElemsNnode*1)
*Set Var CurrentType=Operation(ElemsType*1)
*#
*ElseIf(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"NONLINEAR")==0 && strcmp(ElemsMatProp(Material_Prototype),"CC3DInterface")!=0 && strcmp(ElemsMatProp(Material_Prototype),"CC2DInterface")!=0)
*#Set Var CurrentType=Operation(ElemsNnode+AddingNonLinElemID)
*Set Var CurrentType=Operation(ElemsType+AddingNonLinElemID)
*#
*EndIf
*#
*If(strcmp(ElemsMatProp(Material_Prototype),"CCSpringMaterial")==0)
*If(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"LINEAR")==0)
*Set Var CurrentType=7
*Else
*Set Var CurrentType=37
*EndIf
*EndIf
*#
*If(strcmp(ElemsMatProp(Material_Prototype),"CCReinforcement")==0)
*If(ElemsMatProp(Bar_With_Bond,Int)==1)
*Set Var CurrentType=Operation(CurrentType+AddingBarWithBond)
*EndIf
*EndIf
*#
*If(DebugControl==1)
// *ElemsMatProp(Material_Prototype)
*EndIf
*#
*If(strcmp(ElemsMatProp(Material_Prototype),"CCSandwicKubina")==0 )
*If(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"LINEAR")==0 && strcmp(ElemsMatProp(Static_Material_Prototype),"CC3DInterface")==0)
*Set Var CurrentType=Operation(ElemsType+AddingGapElemID)
*#
*ElseIf(strcmp(ElemsMatProp(Geometrical_Non-Linearity),"NONLINEAR")==0 && strcmp(ElemsMatProp(Static_Material_Prototype),"CC3DInterface")==0)
*Set Var CurrentType=Operation(ElemsType+AddingGapElemID+AddingNonLinElemID)
*#
*EndIf
*EndIf
*#
*Set Var CurrentType=Operation(CurrentType+AddTranspAnalysis)
*Set Var groupID=Operation(ElemsMat*IncrMaterialID+CurrentType)
*#
*If(ElemConstrActiv==0)
*Set Var vonmises2D=strcmp(ElemsMatProp(Material_Prototype),"CC2DBiLinearSteelVonMises")
*Set Var planestress=strcmp(ElemsMatProp(Material_Prototype),"CCPlaneStressElastIsotropic")
*Set Var planesteel=strcmp(ElemsMatProp(Material_Prototype),"CCPlaneStressSteel")
*Set Var dummy=strcmp(ElemsMatProp(Material_Prototype),"CCDummyMaterial")
*#
*If( groupID > oMaxIndexElemGroups )
*#
*If((ndime==3 && vonmises2D!=0 && planestress!=0 && planesteel!=0) || ndime==2)
*Set Var oMaxIndexElemGroups=groupID
*EndIf
*EndIf
*If(groupID<oMinIndexElemGroups)
*If((ndime==3 && vonmises2D!=0 && planestress!=0 && planesteel!=0 && dummy!=0) || ndime==2)
*Set Var oMinIndexElemGroups=groupID
*EndIf
*EndIf
*EndIf
*#
*#
*#
*If(ElemConstrActiv==1)
*#
*# Set Var i2index=Operation(groupID+AddingConstruction*groupID)
*Set Var groupID=Operation(ElemsMat*IncrMaterialID+CurrentType)
*#
*EndIf
*#
*# -------------Za rutinou-------------
*# ElemConstrActiv *ElemConstrActiv
*# oMinIndexElemGroups *oMinIndexElemGroups
*# oMaxIndexElemGroups *oMaxIndexElemGroups
*# ElemConstrActiv *ElemConstrActiv
*# groupID *groupID
*# i2index *i2index
*# CurrentType *CurrentType
*# oldElemsMat *oldElemsMat
*# -------------------------------------
*Set Var oldElemsMat=ElemsMat