Just a couple of things. First the above error, Cannot create instances of CurveObject because it has no public constructors. This is after picking the curve. What have I done incorrectly?
Then, a question on unpacking. I’m familar with this now, but a little bit thrown by the documentation which states:
public static Result GetOneObject(
string prompt,
bool acceptNothing, ObjectType filter,
out ObjRef rhObject
What’s the difference between the ‘out’ and usual ‘returned’ value ? I noticed that I can unpack it the two variables nicely, but want to know the distinction between these two terms. Or is it a C# term? At first I thought it was an extra argument.
out is a keyword in C# which is used for passing the arguments to methods as a reference type. It is generally used when a method returns multiple values.
Python does not have syntax for specifying whether a method paramter is passed by-reference since arguments are always passed by-value. in python you can return multiple values by simply return them separated by commas (tuple).
def test():
return 'abc', 100
a, b = test()
print(a)
# abc
print(b)
# 100
Is this not a bit misleading? Although I know it’s probably just me. So I notice the same thing in GetNumber - it returns a Result, outs / refs a double.
Thank you for that link! Glad that I asked, and I’ll take the silver lining of being pointed to an intermediate level link
Sorry - one other question if you (or anyone) will.
From the Curve.Offset method, I get an array back of type Rhino.Geometry.Curve [ - ] . What’s the best way to approach this kind of object in Python, and where does the Array type come from? I only ask since it’s not a standard Python datatype like a list (forgive my use of datatype).
For now I have assigned the result of Curve.Offset to offset_crv_array, and set offset_crv = offset_crv_array [0]. Covenient in this simple case, but maybe there is a more correct / elegant / accepted way of handling the returned array.
.NET arrays can be indexed and iterated over as if they were Python lists, You can also check for membership using ‘in’ and test their length with ‘len’.
Turning a .NET array into a Python list is trivially easy:
Thanks for this, yeah it’s more the ‘origination’ of the Array which confused me. So it’s a .NET … should I say, storage method? (whatever the right syntax is for this, equivalent to what a list/tuple is in python)