*#a 
*Set Var ax=0.0
*Set Var ay=0.0
*Set Var az=0.0
*Set Var j=LocalNodes(1)
*Set Var ax=Operation(NodesCoord(*j,1))
*Set Var ay=Operation(NodesCoord(*j,2))
*Set Var az=Operation(NodesCoord(*j,3))
*#b
*Set Var bx=0.0
*Set Var by=0.0
*Set Var bz=0.0
*Set Var j=LocalNodes(2)
*Set Var bx=Operation(NodesCoord(*j,1))
*Set Var by=Operation(NodesCoord(*j,2))
*Set Var bz=Operation(NodesCoord(*j,3))
*#c
*Set Var cx=0.0
*Set Var cy=0.0
*Set Var cz=0.0
*Set Var j=LocalNodes(3)
*Set Var cx=Operation(NodesCoord(*j,1))
*Set Var cy=Operation(NodesCoord(*j,2))
*Set Var cz=Operation(NodesCoord(*j,3))
*#ab
*Set Var abx=Operation(bx-ax)
*Set Var aby=Operation(by-ay)
*Set Var abz=Operation(bz-az)
*#ac
*Set Var acx=Operation(cx-ax)
*Set Var acy=Operation(cy-ay)
*Set Var acz=Operation(cz-az)
*#normal_maybe
*Set Var nx=Operation((aby*acz)-(acy*abz))
*Set Var ny=Operation((abz*acx)-(acz*abx))
*Set Var nz=Operation((abx*acy)-(acx*aby))
*#// a= *ax *ay *az
*#// b= *bx *by *bz
*#// c= *cx *cy *cz
*#// ab = *abx *aby *abz
*#// ac = *acx *acy *acz
*#// normal = *nx *ny *nz
*# [ccx ccy ccz] are coordinates of center of element
*Set Var ccx=0.0
*Set Var ccy=0.0
*Set Var ccz=0.0
*for(i=1;i<=ElemsNnode;i=i+1)
*Set Var ccx=Operation(NodesCoord(*i,1)+ccx)
*Set Var ccy=Operation(NodesCoord(*i,2)+ccy)
*Set Var ccz=Operation(NodesCoord(*i,3)+ccz)
*#// bod *i = *NodesCoord(*i,1) *NodesCoord(*i,2) *NodesCoord(*i,3)
*End
*Set Var ccx=Operation(ccx/ElemsNnode)
*Set Var ccy=Operation(ccy/ElemsNnode)
*Set Var ccz=Operation(ccz/ElemsNnode)
*#// cc= *ccx *ccy *ccz
*#good_direction
*Set Var gdx=0.0
*Set Var gdy=0.0
*Set Var gdz=0.0
*Set Var gdx=Operation(ccx-ax)
*Set Var gdy=Operation(ccy-ay)
*Set Var gdz=Operation(ccz-az)
*#// good_direction = *gdx *gdy *gdz
*#scalar
*Set Var s=Operation(nx*gdx+ny*gdy+nz*gdz)
*#// scalar = *s
*if(s<0)
*Set Var nx=Operation(-1*nx)
*Set Var ny=Operation(-1*ny)
*Set Var nz=Operation(-1*nz)
*EndIf