How to use OnPingDocument method on Rhino8

For outputting the path of the Grasshopper document I work on, I have used the code below which is shown on the YouTube channel of prof. Jose Luis’s Parametric Camp. But after installing Rhino 8, the IntelliSense of the C# component doesn’t acknowledge this way. Looking a new Grasshopper SDK, GH_Document.Owner property looks to be changed partly. Dose anyone let me know how should I change the code?

private void RunScript(ref object Here)
{
GH_Document doc = owner.OnPingDocument();
string filePath = doc.FilePath;
string pathOnly = Path.GetDirectoryName(filePath);
Here = pathOnly;
}

Hi, I just struggled with this issue. Apparently, there’s no more need to do OnPingDocument as the property you need can be accessed directly from the GrasshopperDocument member:

string filePath = GrasshopperDocument.FilePath;

You might want to check for nulls (if the file hasn’t been saved yet, FilePath property is null).

Sorry that I couldn’t be aware of your answer.
Thank you so much, I could confirm your way!

1 Like