Rs.ObjectGroups() - bug?


#1

If an object is not a member of any group, rs.ObjectGroups returns an empty list. Methinks it should return None… VB rhinoscriptsyntax returns Null in this case…

Thx, --Mitch


(Giulio Piacentino) #2

Hi Mitch

I’ve opened an issue for this: https://github.com/mcneel/rhinoscript/issues/7
However, this is not strictly a bug. According to the help file, this funtion

Returns all of the group names that an object is assigned.

And in the help, the return value is:

List -- A list of all group names for the object if successful.

So changing this now might actually be slightly unexpected for some people. However, as empty list evaluate to False, you could always do as in the example in the help.

I hope this helps,

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#3

Hi Giulio,

Thanks, I got that. I am simply trying to make sure that vb Rhinoscript and Python rhinoscript are as parallel as possible in this case. This is one of several cases (many of them have been reported) where there are slight differences in what a particular method returns if it doesn’t find anything… The big question is how “if successful” is interpreted…

Cheers, --Mitch


(Steve Baer) #4

I don’t understand what you mean here Mitch. Is there something I need to change with the rhinoscriptsyntax functions?


#5

Hey Steve,

The Help says this:

Returns
List A list of all group names for the object if successful.
(which somehow implies that it might be unsuccessful sometimes)

If no groups are found for the object, then one logical way of thinking about it is “The method was successful, but 0 groups were found” and return an empty list - which is what it does now…

However, another logical way of thinking about it is “The method was unsuccessful because 0 groups were found” and return None. This is what the parallel VB Rhinoscript function does, it returns Null if no groups are found. The Help there has an extra line:

Null If not successful, or on error.

So, my main concern is keeping things consistent between the two Rhinoscripts. However, I can live with it staying the way it is, if I (and others) know what’s happening. If it stays as it is, the Help should then clearly specify:

Returns
List A list of all group names for the object if successful. An empty list is returned if no groups are found
None on error.

Does that make sense?

–Mitch


(Steve Baer) #6

Makes sense to me. You’re being picky and I like that :smile: The more explicit I am about exactly what happens on return from functions, the better.


#7

Oh, it’s worse than that, Steve. IMHO anything less than clear depiction of all possible functions, inputs, outputs and returns is just sloppy documentation. Almost all is not good enough. Not clear is not good enough. It’s certainly not developer friendly.

Fortunately, you don’t go this way very often.

The nice thing about being a programmer instead of a deep sea diver, fighter pilot or race car driver is that your carelessness doesn’t kill you or anyone else. Unless you’re writing software for those professions. Or you’re so consistently careless and cavalier that users come hunting for you.


#8

Yep, I’m a real stickler for order and details… you know… Swiss… :watch: :smile:

–M


(Steve Baer) #9

In my own defense, I wouldn’t say that I was careless in this case either.