Comment: # First we pull in the standard API hooks

Continuing the discussion from How to create a component deinition without drawing?:

There is nothing you normally do to “pull in the standard API hooks.”
The API “hooks” are written on the C-side and compiled into the application binary. They are loaded when SketchUp is loaded, and all ready to go.

(There is a command line switch to start SketchUp with no Ruby API, but it’s use is obscure.)

This comment (above) has become a bad joke. It results from a SketchUp staff member trying to “dumb down” the reason for the require statement below:

You require code IF you need to use it.

And you haven’t. Read the “sketchup.rb” file. It’s in the “Tools” sub-folder of the application directory.

I’d like to compile a list of all examples that have this erroneous “pull in hooks” comment so they can be purged.

Please post the filenames in this thread.

The API classes are not available as Ruby files so we do indeed not have any possibility (and need) to require them. And the little what the sketchup.rb actually contains is often not needed. The comment line is certainly not precisely formulated.

But SketchUp Ruby scripts/plugins/extensions still require a special embedded Ruby that provides these API classes. If one attempts to run them outside, they should fail (at load time and not somewhen late at runtime).

The requirement is probably meant as marker statement and not a litteral requirement of the little bits that this file currently contains.

How else would you suggest to “mark” scripts so that they need a special environment? Also if the Ruby API was implemented as a sketchup.rb that loads a C extension, would it be better? I sometimes drop in alternative SU API implementations (mocks) for ease of testing in the system ruby interpreter, where a sketchup.rb requirement makes sense again.

NO. It is meant as it reads. I find it ridiculous that statements should mean something other than what they actually say.

This thread is about the poor comment that is misleading.

The debate over the use of require "sketchup.rb" is a separate issue. (We can split this off., but I’ll always stand by “only require what you need”.)

ADD: Split off topic:
:point_right: To require “sketchup.rb”, or not to … that is the question