Rhinoscript: how to pass results array to function expecting string object name

Newbie to Rhinoscript - please be nice

Rhinoscript code patch:
strLine1 = Rhino.AddLine(arrStart, arrArcStart)
strLine2 = Rhino.AddLine(arrStart, arrArcEnd)
strLine3 = Rhino.AddLine(arrArcStart, arrArcEnd)

arrTri = Rhino.JoinCurves(array(strLine1, strLine2, strLine3))
strStartingTaper = Rhino.AddRevSrf(strTri, array(arrArcStart, arrArcEnd))

AddRevoledSurface wants the profile curve specified as a string (Id of Object???)
I can look at the views in Rhino and see my perfectly formed, closed triangle(after the join), so I would think it would be an object. How can I get this object id to pass to AddRevSrf as a string? So, how can refer to the joined triangle, or how might I create a suitable object whose id I can pass??

Thanks,
Jim

Hi @jimabshire,

In your code snippet, the arrTri as a result of JoinCurves is an array that contains 1 element (1 curve @ array index 0). It is because this method can possibly return many joined curves.

So the last line AddRevSrf first argument should either be arrTri(0) or insert a line before last one: strTri=arrTri(0)

hth,

–jarek

Thanks very much. That was exactly what I needed to know. Worked perfectly.

Is there source code available for the Rhino library (as with Java)? It would be a boon to all programmers to have a more detailed understanding of what is returned in each array element. It that publicly documented somewhere? Is there something in Rhinoscript which will Display the contents of an array (in a msgbox??)

Thanks for the help!

Jim

In RhinoScript help file, each method is documented in detail - what types of variables it takes (required and optional ones) and also what type of result it returns. It should be a good reference for you in cases like that.

You can always add some test code to your script to print/display the variables content, but the built-in script debugger in editor may be a better option - you basically add ‘break points’ (red dots) between the lines of code where you want your script to stop and show you the status of all variables. See a simple clip that should explain it better: http://screencast.com/t/3rRMFhF9

hth,

–jarek

Thanks for the tip on the debugger. I have been relying heavily on the documentation, but the part that is missing is meaning of the contents in the returned array elements.

When we use the various methods and the return value is an array, is it likely that the first value (0) contains the objectname for the returned structure? Is that a coding standard Rhino follows? That would be extremely helpful to know.

Most languages nowadays will return only 1 value and it has to be an array - if the function needs to provide more info back to the calling program than a scalar can handle. But that means we must have more detail than simply knowing that an array is returned. We need mapping of the data structures returned or a schema or something to work with the returned information.

If this already exists somewhere in the docs, please point me to that. And thank you again for your expert insights and patient handling of my questions.

Jim

Jim,

actually, with RhinoScript it is not as convoluted as you may think. The methods are returning either a single value (whether it is a string, integer, Boolean etc.) or an array - a list of values. Many times the array would be just a list of the same values, but sometimes each value in the array will be of different type, sometimes even another array inside the main one. But all of this is described in detail in RhinoScript help file which I think is actually very well documented.

For example, check out the RhinoScript Help File for the example methods below:

Rhino.PluginName : always returns a single value: string
Rhino.ObjectLayer : returns a single value, but the type depends on the method input
Rhino.JoinCurves : returns an array of same type - object ID strings

I have been relying heavily on the documentation, but the part that is missing is meaning of the contents in the returned array elements.

The Help file says: “Returns: An array of strings identifying the newly created curve objects if successful.

Rhino.MeshClosestPoint: returns an array of 2 different value types (3d point as array and a face index)
Rhino.GetObjectGrips: returns and array of mixed data (grip owner(object ID string), grip index (integer) and 3d point of grip location (array of x,y,z values)

There are even more complex ones, but in each case the Help file describes the returned values in detail.
Obviously all of the above methods (and all other ones in RS) will return Null if something went wrong or missing.

Hope this makes more sense now.

Best,

Jarek

Hi there,

If you type editScript. The editor will open with a lot of libraries on the left.
I went to Curves > Join Curves > double click on it and this opens:

As you can see at Returns > Array meaning it is possible for multiple objects. Also there is an example script that shows how you can use it.

-Jordy

Thank you both very much! A more careful reading on my part would have helped.

Jim