by Dan Rathbun » Thu Jul 15, 2010 4:14 am
Updated again... all methods now at 0.6.0
Fixed several typo booboos. (to myself I says, "Dang! I thought I changed that back in Rev 0.3.0, and my Rev Block says I did. Must be getting old.")
And (prompted by another topic, where I was reminded of the dangers of iterating the C++ collections,) I revised the search methods to use Array copies. Even though they are not changing anything (in the other post, the poster was doing a similar non-changing search "in the context of a larger block of code," and somehow something ELSE (perhaps an Observer, perhaps Sketchup itself,) changed the Entities collection in the middle of the search, causing iterate errors.
Whilst, I did that.. I also switched to using .length to get the size of the list, because it seems to be common between SU's C++ collections, and Ruby Arrays. Whereas the aliases, .count (SUAPI) and .size (Ruby) are not. (So if someone switched back to using the collection, it would not break the code, and visa versa. Note to self: I'll need to remember to always use .length from now on, in this situation.)
Also fixed a stupid error in the conditional expressions, of both the .glued_to? methods. Basically I half reordered them from IF to UNLESS, but forgot to swap the true and false blocks, which has now been done. (Reason for this. For clarity, I like to have the raise Exception statements, in the same order as the boolean tests. If there's only one exception raised, the I usually use an IF expression, and the Exception is raised is in the ELSE block. But, if there are 2 exceptions raised, because of a nested conditional expression [as in this case,] it seems confusing to have the 1st raise exception, shown after the second. So I like to use an UNLESS for the outer expression, with the 1st exception in the upper 'false' block, and the nested conditional (normally an IF expression,) that raises the 2nd exception, down in the unless' ELSE block. That way the raised exceptions appear in the same order as the boolean tests.)
Make sense ??
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5042
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced