I also tried running it with the code below to ensure that the linear units show up as feet instead of foot.
templateFile=arcpy.GetParameterAsText(0)
if templateFile != "":
sr_object=arcpy.Describe(templateFile).spatialreference
units=""
if sr_object.linearUnitCode==9002:
units="Feet"
else:
units=sr_object.linearUnitName
arcpy.env.MTolerance=sr_object.MTolerance
arcpy.env.MResolution=sr_object.MResolution
arcpy.env.XYTolerance="{0} {1}".format(sr_object.XYTolerance,units)
arcpy.env.XYResolution="{0} {1}".format(sr_object.XYResolution,units)
arcpy.AddMessage(arcpy.env.MTolerance)
arcpy.AddMessage(arcpy.env.MResolution)
arcpy.AddMessage(arcpy.env.XYTolerance)
arcpy.AddMessage(arcpy.env.XYResolution)
arcpy.FeatureClassToFeatureClass_conversion("Mylayer","//Path//to//gdb", "OutLayer")
The AddMessage results then were:
6.213699494949262e-07
6.213699494949262e-08
0.003280839895013 Feet
0.0010763910416709318 Feet
This didn't make a difference in the behaviour of the script. It's still pretty erratic. It doesn't work 99% of the time and then it will randomly work out of the blue with no changes to the code.