algorithmic modeling for Rhino
Hi,
I would like to use a specific API library within a rhino.python component.
It works with a vb.net component by using the Manage Assembly option, and choosing my .dll file (Interop.RobotOM.dll). But I don't know how to do it with a rhino.python component. The question is : where do I have to copy my dll file ? I tried to copy it into \Plug-ins\IronPython\Lib, but there are only .py files.
Same problem with AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython\settings\lib
Do I have to convert my .dll into a .py file ? And how ?
Tags:
Replies are closed for this discussion.
Perhaps you could experiment with importing .NET assemblies. This is how for the Grasshopper.dll:
that's right
you might need otherwise
import clr
clr.AddReferenceToFileAndName("C:\...........")
so it gives you the chance to add the whole file path
I tried :
import clr
clr.AddReferenceToFileAndName("C:\Program Files\Version d’évaluation de Rhinoceros 5.0 90 jours\Plug-ins\IronPython\Lib\Interop.RobotOM.dll")
But I got the following message :
Runtime error (MissingMemberException): 'module' object has no attribute 'AddReferenceToFileAndName'
Traceback:
line 7, in script
You can see the clr methods by going like this:
import clr
print dir(clr)
I'm not sure but the one you're looking for might be "AddReferenceToFileAndPath". While troubleshooting you might also want to copy your .dll to the same directory as the Grasshopper.dll and then try to import it like I suggested above. If that works it stands to reason that the other methods should work. Finally there may also be issues with the formatting of the filepath.
sorry for the "tofileandname" thing.
nders is right it is tofileandpath actually.
OK,
I am a beginner with Python.
I tried :
import clr
clr.AddReferenceToFileAndPath("C:\Program Files\Version d’évaluation de Rhinoceros 5.0 90 jours\Plug-ins\IronPython\Lib\Interop.RobotOM.dll")
Seems to work (no error message), but now, I can I have access to my library ?
For rhinoscrit, i write 'import rhinoscriptsyntax as rs', then I can call a class by using toto = rs.AddArc(), for example.
Here, I did not give a name to my new library. I can I do that ?
You still have to import your .dll after adding the clr reference (see my first reply again with the Grasshopper example). You can use any alias you like using the "as" keyword. So in your case you probably want something like this:
import clr
clr.AddReferenceToFileAndPath("C:\Program Files\Version d’évaluation de Rhinoceros 5.0 90 jours\Plug-ins\IronPython\Lib\Interop.RobotOM.dll")
import Interop.RobotOM as irobot
Adding this line gives this message :
Runtime error (MissingMemberException): 'LightException' object has no attribute 'RobotOM'
That probably has to with the (rather odd) full stop in the .dll name acting like a dot operator (that is that Python thinks you're trying to access the method RobotOM on the object Interop). Other than that I have no more ideas!
the name that you must import after adding the clr reference may be different than the .dll name
for example, if I added a clr reference to the rhinocommon.dll, I would then import it using
import Rhino
because Rhino is the name defined within the dll.
Basically, you need to check the documentation for your .dll, and perhaps check how it is imported in C# or other languages.
That's correct !
The right name to import is not Interop.RobotOM but RobotOM. Now it works. The final syntax is :
import clr
clr.AddReferenceToFileAndPath("C:\Program Files\Version d’évaluation de Rhinoceros 5.0 90 jours\Plug-ins\IronPython\Lib\Interop.RobotOM.dll")
import RobotOM as rbt
Thanks a lot !
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by