Placing components within a model by x and y not the mouse

This is in line with the error received from an abstract load handler class doing …

Testing::LoadHandler::new(
  "https://allanblock.com/sketchup/TestBox.skp", [10, 10, 0]
)
module Testing  # <---<<< Change to your namespace
  class LoadHandler

    attr_accessor :error

    def initialize(url = nil, transform = IDENTITY)
      load(url, transform) if !url.nil?
    end

    def cancelled?
      return false
    end

    def load(url, transform)
      model = Sketchup.active_model
      definitions = model.definitions
      # Reset the url and success flag before each load attempt:
      @url = url
      @success = false
      definition = definitions.load_from_url(url, self)
      if @success && definition.is_a?(Sketchup::ComponentDefinition)
        model.active_entities.add_instance(definition, transform)
      end
    end

    # @param [String] error_message
    def onFailure(error_message)
      self.error = error_message
      Sketchup::set_status_text('')
      UI.messagebox("Error downloading from URL:\n #{@url}\n #{error_message}")
    end

    # @param [Float] percent
    def onPercentChange(percent)
      Sketchup::set_status_text("loading: #{percent.round}%")
    end

    def onSuccess
      @success = true
      Sketchup::set_status_text('')
      puts("Download successful from URL:\n #{@url}\n")
    end

  end # class
end # module

(scroll to see all code)

EDITED:(2023-02-01) : Fixed, ie load_from_url() must return before placing component instance.

EDITED:(2023-02-02) : Simplified and changed so that an instance can be reused for multiple downloads.
To reuse a loader instance, create it without arguments so the @url attribute will be nil and the constructor will not call the #load() method.
Then your code can call the #load() instance method any number of times.

For example you might have a hash with filename keys each with a transform value and you want to batch load them:

# base_url is a string URI to where the files are located
# load_set is the hash with "filename" / transform pairs

loader = Testing::LoadHandler.new

load_set.each do |file, transform|
  loader.load( File.join(base_url, "#{file}.skp"), transform )
end

loader = nil # Let garbage collection clean it up

:nerd_face: