Getting compiled PlugIn directory on Mac fails with error

Hi there,

i have compiled some scripts into a PlugIn which runs on Windows and Mac. One of my PlugIn commands should open a helpdoc in pdf format which is placed in the Shared directory using the new ScriptEditor before building the PlugIn. The command to open the helpdoc gets the PlugIn by guid using this code:

plugin_guid = System.Guid("6b8644a1-b6eb-4bef-8cb7-1317e25e95a0")
plugin_file = Rhino.PlugIns.PlugIn.PathFromId(plugin_guid)

if not plugin_file: 
    msg = "PlugIn with guid '{}' not found, please install first."
    print msg.format(plugin_guid)
    return

# get the full path
plugin_path = System.IO.Path.GetDirectoryName(plugin_file)
shared_path = System.IO.Path.Combine(plugin_path, "Shared\PM_Help.pdf")

if not System.IO.File.Exists(shared_path):
    msg = "Error - file not found in 'Shared' PlugIn directory: {}"
    print msg.format(shared_path)
    return
else:
    return shared_path

This works fine under Windows, however on Mac i get this (my) error message:

Error - file not found in ‘Shared’ PlugIn directory:
/Users/clement/Library/Application Support/McNeel/Rhinoceros/packages/8.0/MyPlugInName/0.1.9+9150/Shared\PM_Help.pdf

Does someone know how to fix this ? The path shown above exists as well as the pdf file.

thanks,
c.

Use a the correct directory separator between Shared and the pdf file: Path.DirectorySeparatorChar Field (System.IO) | Microsoft Learn

Or use Path.Combine

1 Like

Thank you so much @menno, it works.

_
c.

Funny enough you already are using Path.Combine. So you can do just

shared_path = System.IO.Path.Combine(plugin_path, "Shared", "PM_Help.pdf")
3 Likes