Community
I honestly can't say how the selectall method translates to internal code, but when I use it, my purpose is to reduce the size of the list I have to loop through, not to mention avoiding having to type check the object, because I know they are all blockrefs (or whatever I filtered to).
In theory, using SelectAll without a filter would give you all entities in modelspace, without having to get the ModelSpace ID and open the modelspace BTR. It probably would be similar IL code, but would have a couple fewer lines of VB code, and no transaction neccessary (until you try to do something with the objects).
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">Well,
you made me curious, so I threw together a really quick, as simple as possible
comparison. Two subs which both ultimately do the same thing, but one uses
SelectAll with a filter, and the other Loops the modelspace. Both look for a
BlockReference, with Attributes, named "FRED", and moves them by (100, 100,
0). I have attached the class for the benefit of the OP.
The
disassembled IL code actually ends up about 20 lines shorter on the Model Loop
method, and it is interesting to note that it takes a little over 30 lines of
IL code (~10 each) to declare the TypedValues to pass the SelectionFilter
constructor.
As for which one is faster, I think you would have to have
an enormous model for it to be measurable. I suppose I could have put a
stopwatch in both of them, and maybe cause them to iterate 1000 times to
exaggerrate the difference, but I did not.
Edited by: chiefbraincloud
on May 11, 2009 5:33 PM
BTW: I would have attached the IL code, but you
can only attach one file, and I didn't want to throw all of it into one text
file. If anyone really wants to see the IL code, you'll just have to build the
class and disassemble it yourself.