Surface.TryGetCone Method C# in grasshopper

hello, everyone I know very little about C# in grasshopper. How do I import this function “Surface.TryGetCone Method” in C# grasshopper? Actually, I don’t know how to use this command in rhino either. But its name looks like very much what I want to achieve. I have a double-curved surface, I need to find a cone which is very close to the surface.

Thanks very much!

private void RunScript(Surface srf, ref object A)
{
  Cone cone;
  srf.TryGetCone(out cone, RhinoDocument.ModelAbsoluteTolerance);
  A = cone;
}

TryGetCone.gh (5.6 KB)

Thanks very much, Mahdiyar, I tried the file you uploaded, it seems this command only works in a strict condition. I rebuild the reference surface, then it doesn’t work anymore. Is there a way of changing the tolerance or something like that to work for more situations?

Can you upload your surface?

TryGetCone (2).gh (10.5 KB) this one

TryGetCone.gh (3.2 KB)

thx very much )