Get plug-in object using RhinoCommon

Hello Community,

I try to get the plug in object using RhinoCommon in python but the RhinoCommon function keep returning me None…

I am sure that I missed somthing…

Here the code trying to get the plug in “Calc” object in standard in Rhinoceros.

# coding=utf-8

import rhinoscriptsyntax as rs
import Rhino 
import scriptcontext 


def Main():
	
	
	IdPlugIn = Rhino.PlugIns.PlugIn.IdFromName("Calc")
	
	objPlugIn = Rhino.PlugIns.PlugIn.Find(IdPlugIn)
	
	print IdPlugIn , " " , IdPlugIn.GetType()
	print objPlugIn
	
	
	return


if( __name__ == "__main__" ):
	Main()

It return:

f967607d-dfdc-497e-9fa6-28acedd332c7   System.Guid
None

I thank you in advance for the hand.

Loïc

PS : I use the last SR 9 version 64bit

What do you need to get a plug-in object? What are you trying to do?

Hello,

I am develloping a small updater for my small Rhino plugin that I devellop. I wanted to create a button to activate / not the plugin…

All is working fin for the updater part, the only thing I need to grab the plugin version. I wanted to use the existing function in the RhinoCommon.

I want to get the plugin object to access to some properties / methode like: Rhino.Plugins.plugin.LoadTime or getting the version, etc…

The fucntion I am trying to use is supposed to return the object for the Guid but it still returning None.

I am sure I do something wrong, but what?!?

Thank’s

Something’s not right with RhinoCommon. I’ll look into it.

In the mean time, if you need the version number of an assembly, you might look into doing something like this:

AssemblyName.GetAssemblyName("plugin.rhp").Version

Thank you very much Dale.

Congrate to you and your team for the fabulouse software & for you reactivity.

You temporary solution helps me a lot!

Thank’s

Loïc

Have to revive this today as i was learning about PlugInObject and tried playing around with it.

This sample code still breaks:

var id = Rhino.PlugIns.PlugIn.IdFromName("BlockEdit"); // id={f2231a2f-66bf-4558-94ce-988c15aede65}
var editPlugIn = Rhino.PlugIns.PlugIn.Find(id); // editPlugIn = null

Did some further poking around and whatever magic @nathanletwory has going on, his plugIns can be loaded. Even my plugIns fail to load, do i have to decorate them in any form to make them available @dale?

Here is the dump of all plugIns:

  Listing all plugIns that could not be loaded:
PlugIn WebBrowser could not be loaded!
PlugIn Renderer Development Kit could not be loaded!
PlugIn RPC could not be loaded!
PlugIn Rhino Bonus Tools could not be loaded!
PlugIn Rhino Labs Tools could not be loaded!
PlugIn AnimationTools could not be loaded!
PlugIn IdleProcessor could not be loaded!
PlugIn Rhino Render could not be loaded!
PlugIn AssemblyLibrary could not be loaded!
PlugIn Renderer Development Kit UI could not be loaded!
PlugIn Snapshots could not be loaded!
PlugIn Alerter could not be loaded!
PlugIn IronPython could not be loaded!
PlugIn ScaleOverlay could not be loaded!
PlugIn Grasshopper could not be loaded!
PlugIn LNurbs could not be loaded!
PlugIn PDF Export could not be loaded!
PlugIn 3Dconnexion 3D Mouse could not be loaded!
PlugIn BlockEdit could not be loaded!
PlugIn Displacement could not be loaded!
PlugIn SolidTools could not be loaded!
PlugIn import_3MF could not be loaded!
PlugIn Export_FBX could not be loaded!
PlugIn MeshFromPoints could not be loaded!
PlugIn RhinoScript Editor could not be loaded!
PlugIn Import_FBX could not be loaded!
PlugIn ACIS Export could not be loaded!
PlugIn ZCorp Import could not be loaded!
PlugIn MicroStation file import: import_DGN could not be loaded!
PlugIn Lightwave Import could not be loaded!
PlugIn RhinoScript could not be loaded!
PlugIn VRML Import could not be loaded!
PlugIn export_3MF could not be loaded!
PlugIn X Export could not be loaded!
PlugIn Raw Triangles Export could not be loaded!
PlugIn STL Export could not be loaded!
PlugIn Import_AMF could not be loaded!
PlugIn SLC Import could not be loaded!
PlugIn Import_DST could not be loaded!
PlugIn AutoCAD file export : export_ACAD could not be loaded!
PlugIn Lightwave Export could not be loaded!
PlugIn Windows Metafile Export could not be loaded!
PlugIn VRML/X3D Export could not be loaded!
PlugIn Squish could not be loaded!
PlugIn export_OBJ could not be loaded!
PlugIn Adobe Illustrator Export could not be loaded!
PlugIn XGL Export could not be loaded!
PlugIn Import_M could not be loaded!
PlugIn CreaseAngle could not be loaded!
PlugIn Points Export could not be loaded!
PlugIn ZCorp Export could not be loaded!
PlugIn OFF Import could not be loaded!
PlugIn SketchUp Export could not be loaded!
PlugIn POV-Ray Export could not be loaded!
PlugIn Tutorials could not be loaded!
PlugIn PLY - Polygon File Format Import could not be loaded!
PlugIn AutoCAD file import: import_ACAD could not be loaded!
PlugIn STEP Import could not be loaded!
PlugIn Renderman Export could not be loaded!
PlugIn MeshCommands could not be loaded!
PlugIn MicroScribe Digitizer could not be loaded!
PlugIn STEP Export could not be loaded!
PlugIn Rhino Options Manager could not be loaded!
PlugIn IGES Export Plug-in could not be loaded!
PlugIn WAMIT Export could not be loaded!
PlugIn IGES Import Plug-in could not be loaded!
PlugIn VDA Export could not be loaded!
PlugIn X Import could not be loaded!
PlugIn RAW Triangle Import could not be loaded!
PlugIn SLC Export could not be loaded!
PlugIn PDFReader could not be loaded!
PlugIn Walkabout could not be loaded!
PlugIn Moray Export could not be loaded!
PlugIn NextEngine Import could not be loaded!
PlugIn MeshTools could not be loaded!
PlugIn GTS Export could not be loaded!
PlugIn Romer Digitizer could not be loaded!
PlugIn WAMIT import could not be loaded!
PlugIn export_xaml could not be loaded!
PlugIn Export SVG could not be loaded!
PlugIn STL Import could not be loaded!
PlugIn VDA Import could not be loaded!
PlugIn SketchUp Import could not be loaded!
PlugIn PLY - Polygon File Format Export could not be loaded!
PlugIn Cult3D Export could not be loaded!
PlugIn General Hydrostatics (GHS) Export could not be loaded!
PlugIn Export_DAE could not be loaded!
PlugIn Solidworks Import could not be loaded!
PlugIn 3D Studio Export could not be loaded!
PlugIn Parasolid Export could not be loaded!
PlugIn Faro USB Digitizer could not be loaded!
PlugIn General Hydrostatics (GHS) Import could not be loaded!
PlugIn Export_AMF could not be loaded!
PlugIn Comma Separated Value Export could not be loaded!
PlugIn E57 Import could not be loaded!
PlugIn Points Import could not be loaded!
PlugIn MPlane could not be loaded!
PlugIn Import_SVG could not be loaded!
PlugIn Calc could not be loaded!
PlugIn GTS Triangle Import could not be loaded!
PlugIn Import_OBJ could not be loaded!
PlugIn Named Position could not be loaded!
PlugIn Denoise Raytraced could not be loaded!

Now listing all PlugIns tha loaded successfully:
PlugIn Commands loaded successfully!
PlugIn BlockManagerQOL loaded successfully!
PlugIn RDK_EtoUI loaded successfully!
PlugIn RhinoCycles loaded successfully!
PlugIn Toolbars loaded successfully!
PlugIn RaytracedBlendMaterial loaded successfully!
PlugIn Rhino Render Next loaded successfully!

From 110 installed plugIns only 7 could be loaded, the other 103 failed to load!

Many of the RhinoCommon plug-in related methods and static functions only work with RhinoCommon plug-ins.

– Dale

Is there a code sample for a rhinocommom plugIn I could refer to?

I doubt it. What problem are you trying to solve?

Here two plug-ins that have publicly facing repositories:

These two are also needed for Raytraced (RhinoCycles) to actually work.

This is my plug-in too.

How are you loading these plug-ins?

Some plug-ins may need other plug-ins to be loaded first. It would be good to have Commands, RDK and RDK UI and RDK Eto UI lug-ins loaded before loading anything else

  1. The problem i wanted to solve was hooking into the BlockEdit plugIn, trying to listen to when the blockManager command is run and overload it with my own code.

  2. Additionally i would like to create a python API for one of my existing plugIns and thought maybe the plugInObject could help me with this. Small mock up:

myPlugInId = Rhino.PlugIns.PlugIn.IdFromName("MyPlugInName")
myPlugInObject = Rhino.PlugIns.PlugIn.Find(myPlugInId)
# mock up function
print myPlugInObject.MyExampleFunction()

All of my plugIns are in RhinoCommon

1 Like

Nothing to fancy i just ran the script above in a loop:

            var names = Rhino.PlugIns.PlugIn.GetInstalledPlugInNames();
            List<string>[] results = new List<string>[2] {new List<string>(), new List<string>()};
            foreach (var name in names)
            {
                var id = Rhino.PlugIns.PlugIn.IdFromName(name);
                var plugIn = Rhino.PlugIns.PlugIn.Find(id);

                if(plugIn is null)results[0].Add(name);
                else results[1].Add(name);
            }

            RhinoApp.WriteLine("Listing all plugIns that could not be loaded:");
            foreach (var notLoaded in results[0])
            {
                RhinoApp.WriteLine($"PlugIn {notLoaded} could not be loaded!");
            }

            RhinoApp.WriteLine("");
            RhinoApp.WriteLine("Now listing all PlugIns tha loaded successfully:");
            foreach (var loaded in results[1])
            {
                RhinoApp.WriteLine($"PlugIn {loaded} loaded successfully!");

            }
            RhinoApp.WriteLine("");
            RhinoApp.WriteLine($"From {names.Length} installed plugIns only {results[1].Count} could be loaded, the other {results[0].Count} failed to load!");

For instance DenoiseRaytraced has the default PlugIn.LoadTime, which is PlugInLoadTime.WhenNeeded. The other two use PlugInLoadTime.AtStartup, so they are already loaded.

Using PlugIn.Find(Guid id) checks already loaded plug-ins. To actually load plug-ins use PlugIn.LoadPlugIn(Guid id) or PlugIn.LoadPlugIn(Guid id, bool loadQuietly, bool forceLoad).

2 Likes