Hi Steve, yes.
_
c.
Hi Steve, yes.
_
c.
That doesn’t make sense. I believe you, it just seems very strange. Rhino gets plugin info from a version/scheme specific registry key and shouldn’t be looking in other keys to find plug-ins. If you open plugin manager in V5 and look at the properties for this plugin, does it show the different path?
Hi Steve, no it shows the correct path which is inside Rhino 4 folder. So it looks like Rhino 4 and 5 are calling that PlugIn from the same path.
_
c.
@clement
Looks like we are missing the “version” folder in the path that installer creates
I would use the following to get the directory for your plug-in
import Rhino
import os
def GetPluginDirectory(plugin_name):
path = Rhino.PlugIns.PlugIn.PathFromName(plugin_name)
if not path: return None
return os.path.dirname(path)
if __name__=="__main__":
dirname = GetPluginDirectory("IronPython")
print dirname
@mikhail, thats funny. I do not have a plugin with such version folder (yet). Just curious, if it doesn’t matter if your plugin can be loaded or not, what is if you try what @stevebaer suggested. eg. what does your compiled PlugIn return when you call this:
print Rhino.PlugIns.PlugIn.PathFromName("Beetle")
If it gives you the full plugin path with rhp extension, you could get the folder like this:
import Rhino
import os
file_path = Rhino.PlugIns.PlugIn.PathFromName("Beetle")
directory = os.path.dirname(file_path)
print directory
then append your icons directory.
_
c.
Hi @stevebaer, just to clear this up. Your method reports the path and plugin file name with extension. It does this even when the plugin cannot be loaded. (This is the case with my “FurGen” example, which expired btw. The example i posted above tries to load the plugin if it is not loaded. If loading fails or it cannot be found as installed plugin, it does not return the path.
_
c.
Yes, the PathFromName
does not report if a plug-in can be loaded or not. It only reports the path to a know plug-in. If you have the plug-in class itself, you can call plugin.Assembly.Location
to get the path to the RHP.
Hi @stevebaer, thanks your the clarification. I can change above example but i would like to know how to get the location if the PlugIn has been installed for all users ?
What i find strange, why is the settings directory returned but not the version directory which should be the parent directory ?
_
c.
Either approach (PathFromName
or plugin.Assembly.Location
) both will work. It doesn’t matter if the plug-in has been installed for the current user or all users; Rhino only knows of one path for each plug-in.
The settings directory is where a plug-in stores it’s saved settings and is not version specific.
BTW: If a plug-in is installed for all users then any changes to toolbars or ini-files are not saved.
Is there something we can do to allow this or is this a windows security setting?
@clement
That worked!
file_path = Rhino.PlugIns.PlugIn.PathFromName("Beetle")
directory = os.path.dirname(file_path)
print directory
myFullPath = directory + '\\icons\\'
print 'myFullPath',myFullPath
this did return fullpath with Beetle.rhi in the string
print Rhino.PlugIns.PlugIn.PathFromName("Beetle")
Thanks @stevebaer, then this would be the slightly revised function from above which checks if the plugin can be loaded by trying to load it when it is not loaded. If it cannot be loaded, it does not return the path.
import Rhino
import os
def GetPluginPath(plugin_name=None, autoload=True):
"""finds installation path of a plugin which must be loadable"""
if not plugin_name: return
plugin_id = Rhino.PlugIns.PlugIn.IdFromName(plugin_name)
rc, loaded, loadprotected = Rhino.PlugIns.PlugIn.PlugInExists(plugin_id)
if not rc: return None
if not loaded and autoload: Rhino.PlugIns.PlugIn.LoadPlugIn(plugin_id)
plugin = Rhino.PlugIns.PlugIn.Find(plugin_id)
if not plugin: return None
path_name = plugin.Assembly.Location
if not path_name: return
return os.path.dirname(path_name)
if __name__=="__main__":
path = GetPluginPath(plugin_name="IronPython", autoload=True)
if path:
print path
_
c.