As the headline says...BaseSelect.GetRange()
returns the min and max values for a segment in a selection. But it has a second parameter (besides the segment), called max
.
Now, max
is not needed from a structural point of view. The selection contains a known number of segments, which contain one tuple each. Other than e.g. BaseSelect.SelectAll()
, where we actually need to pass a max value because the BaseSelect does not know the total number of elements that may possibly selected, GetRange()
does not deal with unknowns.
The documentation says about this parameter:
max (int) –
The maximum value for the returned elements numbers.
Usually pass PolygonObject.GetPolygonCount() or PointObject.GetPointCount() or the edge count of the object.
The method makes sure they are < max.
I would interpret that as assurance that any value we get returned is smaller than max
. So if there is a segment (1,5) and max = 3
, then we'd get (1,3) back. (I can't for the life of me think of a reason why I would want that, but hey.)
That is, however, not what I really get. If I use a value for max
that is smaller than the value GetRange tries to return, I receive TypeError: 'NoneType' object is not iterable
. If I use a ridiculous large value for max
, no apparent effects happen at all, not even a perceivable increase in runtime.
So, I have a parameter that at best does nothing, and at worst throws an error. I don't know whether this is a bug (R21) or whether I just don't understand the function.
The C++ doc says about the same parameter:
The maximum value for a and b. Makes sure a and b are < maxElements. Pass LIMIT<Int32>::MAX for no additional checks.
That supports my understanding of the parameter, but does not explain why I get a TypeError
instead.
(It also doesn't explain why a limit on the selection is so important that it justifies an additional parameter when the check could easily be done on the returned values. Or: what happens, if both returned limits of the segment are larger than max
.)
btw, it would be nice if the Python docs also contained the additional info from the C++ doc:
The spans are always sorted (spans with higher index have higher numbers for a/b), also b is always >= a.