Make toolbar icon using code

Please post code correctly in the forum.

… with TAB characters replaced with 2 space characters.

Because SketchUp’s Ruby cannot find them.

The location on disk of the current interpreted file is got with the global __dir__ method.

You have the icons in a subfolder named "Example Images".

You can build a full path to the files using File.join method.

    cmd.small_icon = File.join(__dir__,"Example Images","Cabinets_small.png")
    cmd.large_icon = File.join(__dir__,"Example Images","Cabinets_large.png")

[I suggest shorter descriptive icon names like: “Cabinets_small.png” and “Cabinets_large.png”]

You might also be able to use the block form of Dir::chdir method (which restores the previous current directory when the block ends.)

    Dir.chdir(File.join(__dir__,"Example Images")) do
      cmd.small_icon = "Cabinets_small.png"
      cmd.large_icon = "Cabinets_large.png"
    end