Use rs.filter.instance
or just ā4096āā¦
Yeah, I saw this but itās easier to remember the word
Thanks Steve. Who wouldāve thought itās an instance
Not for meā¦ plus when you want to combine several different types of filters, the lines get very longā¦
Say I want to limit my selection to surfaces, polysurfaces, meshes, and maybe letās say blocksā¦
rs.GetObjects("Select your stuff", rs.filter.surface | rs.filter.polysurface | rs.filter.mesh | rs.filter.instance, preselect=True)
or
rs.GetObjects("Select your stuff", 8+16+32+4096, preselect=True)
I wouldnāt go that route as a general recommendation. When a named constant (or enum) is provided in a library it is best to use the name. The numbers are a hold over from RhinoScript and make the script difficult to read.
Ever heard of the psychological test where words are written in different colors , but the color doesnāt correspond to the actual color of that word.
Human brain works associatively. I donāt work solely with Rhino, nor program solely with Python. If the number is different the whole process becomes slower and difficult to switch from one to another. Also the code, however short, becomes difficult to read by someone not familiar enough with the numbers.
Perhaps. That is the argument that is always put forth. However, I always assume that people who are delving into rhinoscripting will quickly become familiar with this stuff; and itās not too hard to look up in the help either.
Edit:
And just to add a little spice to this conversation - the advice to spell everything out because it makes the script easier to read is brought to you by the same people who put together these types of examples:
Iāll fix my stuff when you doā¦
And I thought Iām nagging a bit too much.
Collect them into a variable that tells you what you want, then use that
thestuf = rs.filter.surface | rs.filter.polysurface
thestuff = thestuf | rs.filter.mesh # or thestuff = rs.filter.mesh | thestuff, if you like to have The Goods first...
thestuff = thestuff | rs.filter.instance
rs.GetObjects("Whaddayawant?", thestuff, preselect=True)
Why do you use this symbol?
What is the difference to when ā+ā is used?
You can use plus as well in this case, but I use the pipe symbol because you are ORāing the values.
So if the first object is a surface then all subsequent selections will be surfaces? I do not get the OR here.
The numbers you posted in [Python] filtering blocks in rs.GetObject() missing (post 3) are numbers that follow the binary system. ORāing binary numbers like that is like adding them together
01 | 10 = 11
-> 01 + 10 = 11
-> 1 + 2 = 3
Thanks :), that explains a lot.
I guess I wouldāve known this if I was a C/Cpp developer
See a more complete explanation here but with typos in the āorā section, where | becomes & :
http://block.arch.ethz.ch/blog/2016/10/bitwise-operators-in-python/
Why is binary used, though?
yup, and filter
is a reserved method name in python which should not be used as object nameā¦
_
c.