Confusing NameError between Extension and Ruby Console

By coincidence I discovered a confusing NameError when I applied the code below from the Ruby API.

model = Sketchup.active_model
layers = model.layers
layers.add("test layer")
layers.each { | layer | puts }

If you execute the code through the Ruby Console you will not get an error.


If I execute this code in my own extension or through the Ruby Code Editor extension, I get the following name error.


The code will be executed. But it is very confusing why the NameError is displayed.
Because what does Enscape have to do with this?

Can someone tell me why this error is displayed?

Do you have Enscape loading as an extension ?*
*Somehow it’s calling LayerHelperClass from Enscape and not finding it, so I expect it’s as’s problem…
The as_rubyeditor tool seems to be throwing the error, not Ruby itself [the Console version works fine] ??

I have loaded the Enscape extension.
If you execute the code through the Console, there will be no problems.

But if you execute the code in your own extension or, for example, the Ruby Code Editor extension, you will get a NameError. This is strange because the code, in this case, has nothing to do with Enscape.

Something is looking for Enscape::LayerHelperClass
If you inspect the Constants associated with Enscape what do you see?

If it’s a missing constant/class/module reference it won’t appear.
So does Enscape perhaps add a layer-observer, which is faulty, calling a no-existent thing ?
The as_rubyeditor.rb appears to trigger a layer-observer onLayerAdded [line #333] which seems to trigger this weird Enscape error…
However, in as_rubyeditor’s current version v4.1 that line is nothing at line #333 but a ‘commit_operation’ ?
What version of it are you using ?
So I suspects it’s really an Enscape malformed layer-observer error issue…

You really need to contact Enscape [and warn Alex] to get to the bottom of this…

I agree. An Enscape layer observer is interfering with an operation in Alex’s console.

But, that said, because Alex’s console puts an operation around everything it executes, it can cause weird errors and situations (nesting of operations) that I find interferes with the development process (especially for newbs.) So I myself do not use it most of the time, and don’t recommend newbs use it as it “throws them off” chasing problems that will not really exist when an actual extension is loaded and run normally.

Alex’s console (and other similar web consoles) have a place as a learning tool running small snippets of code. But I feel is not well suited for development or debugging extension projects.

@TIG and @DanRathbun thank you for thinking along and your input.
I have been in contact with Enscape and this problem is solved in the next update.