SVG toolbar icons are rendered all black

Which is why your SVG files should probably always include the <!DOCTYPE> declaration that indicates what SVG version the parser should use to read the file.

As long as you use ver 1.1 and stick to style attributes and stay away from inline stylesheets using a <style> element.

But, again it all depends upon whether SketchUp stays with the limited external library it is using now.

Not really. Raster icons do not scale well with display scaling. And coding for vector icons is not much more work at all.

# Test for vector icon support (v2016+) ...
if defined?(::Sketchup::Model::VERSION_2016) # use vector icons
  type = Sketchup.platform == :platform_osx ? 'pdf' : 'svg'
  icon_path = File.join(__dir__,'images',"vector_icon.#{type}")
  cmd.small_icon= icon_path
  cmd.large_icon= icon_path
else # use raster
  type = 'png'
  cmd.small_icon= File.join(__dir__,'images',"small_icon.#{type}")
  cmd.large_icon= File.join(__dir__,'images',"large_icon.#{type}")
end

NOTE: I’m using that fact that the ::Layout module was not defined until SketchUp 2016 as the test for raster vs vector.
CORRECTION: It was the LayOut C API that was released with v16. The ::Layout Ruby API did not come out till 2018. (Changing the above test to Sketchup::Axes.)
CORRECTION (2): The consensus of comments below are for using a version check, so I’m changing the above example, once again (just so future readers seeing only the example are not led astray.)


Thomas just answered this …

2 Likes