Add namespace of plugin on load into IronPython


How do you add references to your C# plugin, and namespaces, into IronPython on plugin load ?
For example, after Grasshopper plugin is loaded (on startup), I am able to import Grasshopper
And is this a recommended behaviour?

Current way to import namespaces from plugin via IronPython script:

import clr
import MyNameSpace


Hi @t.ho,

Does this help?

– Dale

That’s what I’m currently doing.
I’m developing a C# plugin, and want all my namespaces to be available in ironPython programmatically.

Are you experiencing a problem with your current method or is there are you asking if that is the recommended method?

MyPlugin loads in Rhino fine, the problem with the current method is that the IronPython script engine/context requires the following code in order to import MyNameSpace

import clr

I would like Rhino IronPython script engine to add reference to MyPlugin automatically (onload/programmatically) so users do not have to.

i.e. Grasshopper is a Rhino Plugin. when you create a new script in IronPython, you do not have to clr.AddReference("Grasshopper"). This is the behaviour i would like to replicate.

Not possible unless you are planing to write a python wrapper around the .dll file.
This is a limitation of python interfacing with c#.

If you do write the wrapper, you can then put the python file somewhere where the module search path is so that it automatically picks it up.
From python editor, go tools > Options and it is the top textbox.