Custom toolbar editor

Hi All,

I was previously using the toolbar editor to create custom buttons with ruby scripts attached to them, however the toolbar editor is no longer supported for version 2014. Does anyone have a new custom toolbar creator that will do the same thing or know how to make the custom toolbar a different way?

Do you actually mean 2024 with Ruby 3.x ?

If so, is there a Ruby exception appearing in the Ruby console when it loads?

here is the error message that I get, and sorry I meant 2024 and not 2014

You are not showing the error. either click the expand button (down arrow) or the clipboard button and paste the message and backtrace here within triple backtick delimiters.

According to its sketchUcation plugin store page, that extension has not been updated since 2021. It is very likely that is is not compatible with the version of Ruby in 2024. The removal of Fixnum class broke a lot of old extensions.

I didn’t check this because I don’t want to install on SU '24 but I searched the files. If you open:

toolbareditor.rb,
options.rb,
custombuttons.rb,
and bridge.rb

and search “Fixnum”, then replace all instances with “Integer”, the extension might work again.

2 Likes

The errors are definitely from Fixnum elimination in Ruby 3. I’m going to try the substitution to see whether that repairs it, though there are a lot of places that trap Fixnum vs Integer so I’m not certain I understand all of what it is doing…

1 Like

I just closed everything but there were so few that it would be pretty quick to try. At least in the files I listed that have Fixnum, Bignum was not present.

Couldn’t help myself: exists? exists in toolbareditor…

Yep, another ruby 3 change. With those two changes it loads without complaint. I don’t have time to check that it all works properly with the changes. I haven’t seen @Aerilius on the forum for a while, but if this ping reaches him he should fix it on SketchUcation.

Edit: the dialog window right panel spins endlessly on open. There may also be issues with compatibility for the lasted CEF.

1 Like

UI.start_timer in toolbareditor.rb?

Yes, a search finds them …

Search "exists?" (3 hits in 2 files of 47 searched) [Normal: Case]
  C:\Users\Dan\AppData\Roaming\SketchUp\SketchUp 2024\SketchUp\Plugins\ae_toolbareditor\custombuttons.rb (2 hits)
	Line 175:   return nil unless snippet_path && File.exists?(snippet_path)
	Line 191:  Dir.mkdir(DATA_PATH) unless File.exists?(DATA_PATH)
  C:\Users\Dan\AppData\Roaming\SketchUp\SketchUp 2024\SketchUp\Plugins\ae_toolbareditor\toolbareditor.rb (1 hit)
	Line  95:  ].compact.find{ |path| File.exists?(path) && File.writable?(path) }

…

The following registrar file will define local constants for Fixnum and Bignum as well as method wrappers for File.exists?, but not require the susig extension signature to be regenerated.

ae_toolbareditor.rb (1.4 KB)

The file (... click to expand ...)
# AE::ToolbarEditor extension registrar file
# updated 2024-08-15 for Ruby 3.x and SU2024

# Load the normal support files:
require 'sketchup.rb' unless defined?(LanguageHandler)
require 'extensions.rb' unless defined?(SketchupExtension)

# Define and load the extension's VERSION constant:
require File.join('ae_toolbareditor', 'version.rb')

module AE
  module ToolbarEditor

    unless defined?(::Fixnum)
      # Define local aliases for Integer subclasses removed in Ruby 3:
      Fixnum = ::Integer
      Bignum = ::Integer
    end

    unless ::File.respond_to?(:exists?)
      # Define method wrapper for FileTest#exists? removed in Ruby 3:
      module ::FileTest
        define_method(:exists?) { |path| self.exist?(path) }
      end
      # Define method wrapper for File::exists? removed in Ruby 3:
      class ::File
        define_singleton_method(:exists?) { |path| self.exist?(path) }
      end
    end

    # Create the extension data object:
    EXTENSION = SketchupExtension.new('ToolbarEditor', 'ae_toolbareditor/toolbareditor.rb')

    # Attach some nice info:
    EXTENSION.creator     = 'Aerilius'
    EXTENSION.version     = AE::ToolbarEditor::VERSION
    EXTENSION.copyright   = '2013-2021, Andreas Eisenbarth'
    EXTENSION.description = 'A drag&drop editor to create custom toolbars.'

    # Register and load the extension on startup.
    Sketchup.register_extension(EXTENSION, true)

  end
end

…

I see this intermittently. Close the dialog and reopen.

Sometimes it takes a few tries for the buttons to populate the dialog.

Not sure of the cause here.

3 Likes

I’ll try replacing the ae_toolbareditor.rb file with the new file you have created Dan.

1 Like

works like a dream Dan, thanks. Just had to close and re-open the dialog window

1 Like