Dear sir
I am so grateful to you for your detailed answer. Thanks a million.
best wishes
Tao Cui
the surface attribute "calculationFailed" will tell you if the surface calculation succeeded or not, so you could do something other than try to write the DMS file if that attribute is False.