rs.GetObject / Rhinocommon Gets

If you do the following:

get = rs.GetObject( “Pick”, rs.filter.polysurface | rs.filter.surface)

Why does rs.filter.polysurface | rs.filter.surface work, in terms of that style / notation, for being able to throw two possible values in here ? It’s handy but wondered if there is a term for doing this.

I’m trying to use RhinoCommon but I still can’t quite get my head round all the different Gets, even with the help of the samples.

The values are essentially numbers with just one bit turned on. The | is ORing the two values. The result is a number with both bits turned on. Search the internet for the term bitflag.

Thanks Nathan!

So can it be thought of as an overload? Or is it more equivalent to ObjectType Enumeration where you, for example, sum Surface (8) and Brep (16) to get a filter value of 24?

Yes. Not “more” equivalent but exactly equivalent. The addition works because the values are chosen to be powers of 2. This means that each bit in a byte (or in the general case, an integer word) represents one of the logical items stored in the word. From the programming purist’s point of view the real way of assembling various logical conditions into one computer word is to use the logical OR operator.

Byte example: 0 0 0 0 0 0 0 0 <-- LSB (least significant bit) All bits “off” or FALSE
0 0 0 0 0 0 0 1 bit 1 on represented by integer 1
0 0 0 0 0 0 1 0 bit 2 on represented by integer 2
0 0 0 0 0 0 1 1 both bit 1 and bit 2 on, integer 3, ie 1+2, 1 OR 2

1 Like