Hello
I can see RhinoCommon in C# and VB below link, but I cannot find python version of it.
https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm
Where can I find the python source code for Rhinocommon?
Hello
I can see RhinoCommon in C# and VB below link, but I cannot find python version of it.
https://developer.rhino3d.com/api/RhinoCommon/html/R_Project_RhinoCommon.htm
Where can I find the python source code for Rhinocommon?
Not all pages have Python examples. Also, not all pages will have any examples.
See GitHub - mcneel/rhino-developer-samples: Rhino and Grasshopper developer sample code for a collection of sample code in Python, C# and C++
I understand. Thank you very much.
Hello Eisuke, I think it’s the same C# or VB source code. A lot of the compiled functions and methods written in C# are also callable from RhinoPython (Iron Python).
Hello,
I think my getsource script could be modified to get the RhinoCommon source code if you know how to do that?
Yes, I understand that there is almost no difference between python and C#orVB.
But the behaviors of functions written in C# features that are not in python, such as out arguments, are not clearly understood because there is no specification.
In Rhino we use IronPython, in which everything under the hood is a .Net type, even the normal Python core types. This means for example that Iron Python strings have much better support for unicode than CPython 2.7. Also unlike CPython 2, IronPython is actually multi-threaded.
https://ironpython.net/documentation/dotnet/dotnet.html#appendix-type-conversion-rules
A lot of the .Net types can be accessed by import System
. System is one of the special core modules of Iron Python you don’t get in CPython (clr being a particularly powerful one).
Functions can be overloaded in C# (polymorphism) so you have to watch out which version you’re looking at and calling depending on the input args.
There are gaps in the documentation, but the return type of a method is just the property value. If you could point out any particualr RhinoCommon function or method you’re having trouble with, it will be much easier to help explain the spec to you.
Thank you for your detailed explanation.
Specifically, the BrepBrep method was difficult to understand.
The return value is Bool, and in C#, I believe the value is stored in the out argument.
In python, the out argument was in the return value in addition to the Bool return value.
Ah OK, that looks like you call it with two arguments and let the function mutate them. The other dififculty is C# is statically typed, so if the GhPython component doesn’t mange to automagically coerce the input arg for you, then those arguments have to be of the required type. And those types can be a little tricky to instantiate, particularly the generic types (that accept [ ] afterwards):
The call will look something like:
import Rhino.Geometry
curves = Rhino.Geometry.Curve()
points = Rhino.Geometry.Point3D()
`result = BrepBrep(brebA, brebB, tol, curves, points)
if result:
# do something with curves or points
Experimentation and proceeding by trial and error is required. BrepBrep might just accept an empty list for curves and points. That’s worth trying first, I just wouldn’t count on that.
I see, so we have to try it out. Thank you very much.