I’ll repeat some suggestions I think I made on one of your other topics:
- your code needs to test return values from anything that can fail before continuing on with more operations. Often the consequence of a bad value isn’t felt until much later.
- you need to learn how to debug your own code better. Simply run and see what happens is a gamble. Fine if it works, but offering no insight when it fails.
The most primitive yet an effective way to debug is to sprinkle puts statements through the code that report the values of things and watch the Ruby Console to see where things go awry. You can remove them or comment them out when the code seems to be working.
A more sophisticated way is to attach a suitable external debugger via SketchUp’s debugging interface. Going that route involves a much more elaborate setup than the simple puts technique, and requires technical understanding of debuggers in general. But it also avoids the need to guess in advance where the problem lies (to know where and what to report via puts).