Plugin install folder?

Hi guys,
I am trying to find a plugins install folder.
But all I could find was this:

import Rhino

print str(InstalledPlugInFolders)

And that does not tie any of those folders to any plugin. So I must be doing something wrong.
Please help.

I see a way to get all plug-in names and all plug-ins folders, but not a way to get the full path to all plug-ins, which is kind of odd.

If a plug-in is loaded, you can do something like this:

Dictionary<Guid, string> dict = Rhino.PlugIns.PlugIn.GetInstalledPlugIns();
foreach(KeyValuePair<Guid, string> entry in dict)
  Rhino.PlugIns.PlugIn plugin = Rhino.PlugIns.PlugIn.Find(entry.Key);
  if (null != plugin)
    System.Reflection.Assembly assembly = plugin.Assembly;
    if (null != assembly)

I’ll add a wish list item for a method that returns the full path to all plug-ins.

I would like to understand a bit more of what it is you are trying to do first.

I will distribute Holomark 2 together with a 3D file (mini morris) and some display modes. I’ll tell the users to keep these in the same folder. So when Holomark is installed it can automatically locate the other files it needs.

I work around this now by having the user select the folder where the files are. Then all the rest is automatic. But that is not as smooth as I would like it.

I am trying to convert @dale s code to Pyton and I can only find three paths.

(And I keep on forgetting how to format this to python… sorry)

import Rhino
import System.Reflection.Assembly
dict = Rhino.PlugIns.PlugIn.GetInstalledPlugIns()
for entry in dict:
    print entry
    plugin = Rhino.PlugIns.PlugIn.Find(entry.Key)
    if plugin:
        assembly = plugin.Assembly
        if assembly:
            print (assembly.Location)

For this case, I would just do something like the following

import Rhino

id = Rhino.PlugIns.PlugIn.IdFromName("Holomark 2")
plugin = Rhino.PlugIns.PlugIn.Find(id)
path = plugin.Assembly.Location
print path

Since you already know the Guid of your plug-in you could even just write

import Rhino
import rhinoscriptsyntax as rs

id = rs.coerceguid(".........")  #your plug-in's Id
plugin = Rhino.PlugIns.PlugIn.Find(id)
path = plugin.Assembly.Location
print path

Hm… finally got around to test this out, but I get this error:

Message: ‘NoneType’ object has no attribute ‘Assembly’

And Traceback points to this line:
path = plugin.Assembly.Location

I adjusted a few print commands to find the error, and it prints the “id”, so it apperas Plugin.Find() can’t find it.

import Rhino

id = Rhino.PlugIns.PlugIn.IdFromName("Holomark2")
print "id = "+str(id)
plugin = Rhino.PlugIns.PlugIn.Find(id)
print plugin
path = plugin.Assembly.Location
print path

Can you please help me out with this?
Only a few of the installed plugins show their forlders.

I do not know if I understand correctly what you need
I use this to find the path to the plugin on rhinoscript

Function Path()
    	Dim  PathRhp ,strPercorso
		PathRhp = Rhino.PlugInInfo("Plugin gui")
	strPercorso = PathRhp(2)
	strPercorso = replace(strPercorso, PathRhp(1) & ".rhp", "")
	Path = strPercorso
End Function


Are you trying to find the “Holomark2” plug-in from within your python script, or are you trying to find other plug-ins? I’m asking so I can focus on the exact problem you are trying to solve.

I am just trying to find the Holomark2 plugin.
And I want to find the Holomark2 plugin folder when running the plugin.

(But right now I am trying to find the Holomark plugin from within a script :smile: )

Hmm… seems to work for me. Is Holomark2 the name of your plug-in that your script is running in? Look in the plug-in manager and make sure you have the exact same name.

Hmm… seems to work for me too… now… And why is that? Could restarting Rhino have anything to do with it? I’ll have to do some tests on that.

I needed to remove the file name from the path name and did it like this:

import Rhino
import rhinoscriptsyntax as rs

id= rs.PlugInId ("Holomark2")
plugin = Rhino.PlugIns.PlugIn.Find(id)
path = plugin.Assembly.Location

# Holomark2.rhp = 13 letters


print newPath

I like the logic in doing it like that, but is it the most reliable and “propper” way of handling a string?

There are path functions for splitting up strings like this, but in your case this should be fine. For something like this, I find it a little clearer to write something like

pathLength = len(path) - len("Holomark2.rhp")

instead of having a ‘magic’ number 13

I agree, that looks cleaner and easier to update in the future.
I implemented the folder search in Holomark2 now and it works fine on my computer. Hopefully it will work fine on most systems. So thanks again for the help!

Hi guys, I am revisiting this and have an issue with the latest Rhino 5 build where Rhino.PlugIns.PlugIn.Find doesn’t return anything even if I can locate the ID.

import Rhino
import rhinoscriptsyntax as rs

id= rs.PlugInId ("Calc")
print "id = "+str(id)

pluginFind = Rhino.PlugIns.PlugIn.Find(id)
print "find = "+str(pluginFind)

if pluginFind:
    path = pluginFind.Assembly.Location
    print path
    print "no path"

I used “Calc” as example just to simplify things, so replace “Calc” with another pluginname if you want.

The result I get is this:

id = f967607d-dfdc-497e-9fa6-28acedd332c7
find = None
no path

PS! I get the same error in V6. Is something changed with the “Find” command?

Ok, I see there is a Rhino.PlugIns.PlugIn.PathFromId() that I can use instead. None the less, please look into the above :slight_smile:

“Calc” is not a .Net assembly, so “Assembly” makes no sense for .Net. You could try with “Commands” for example, I think that would work.

Ok so “Calc” was a bad example.
The point I wanted to make is that I tested it with my custom plugins, and it doesn’t work like it used to :slight_smile:

Does it work for “Commands”?

Hi Piac, I don’t really understand your question as “Commands” isn’t a listed plugin.
And I think it would be faster for you to try than to ask :wink: