mcneel / ghpython

A Grasshopper component for Rhino.Python
http://www.food4rhino.com/project/ghpython
118 stars 34 forks source link

Python help file #4

Closed sbaer closed 12 years ago

sbaer commented 13 years ago

add link in editor for opening the python help file

piac commented 13 years ago

Can you please point me to the code that does that on the Rhino.Python editor form? Does it have a hard-coded location?

sbaer commented 13 years ago

The python help file is always in the same directory as the python plug-in. Here's the code in the plug-in to get at the help file

System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
string dir = System.IO.Path.GetDirectoryName(a.Location);
string filename = System.IO.Path.Combine(dir, "RhinoIronPython.chm");

You can probably do something similar in the ghpython component by getting the Assembly that the PythonScript object is defined in.

var py = Rhino.Runtime.PythonScript.Create();
var a = py.GetType().Assembly;
string dir = System.IO.Path.GetDirectoryName(a.Location);
string filename = System.IO.Path.Combine(dir, "RhinoIronPython.chm");
piac commented 12 years ago

Done