sketchucation logo sketchucation
    • Login
    1. Home
    2. LFloissac
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    L
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 3
    • Groups 1

    Posts

    Recent Best Controversial
    • Using chunkyPng library with Sketchup

      I need to write a PNG image processed into a Sketchup plugin.
      Note: this image is not a screen copy of Sketchup scene but a process result. So, the SU usual PNG save image method is not suitable for that.

      This is ChunkyPNG library job !
      see http://rubydoc.info/gems/chunky_png/frames

      1. When I launch a simple test program directly from ruby 1.8.6, Its working well.
      2. The same code, with the same path lauched from SU (ruby console) crashs (see above).
      3. I've find a "dirty" solution by creating new Set and SortedSet classes (here attached).
      4. Does someone have a better solution ?

      The problem seems to come from the "set" ruby command who could be overided in the SU ruby engine.

      1. The code of a simple test case:
        $LOAD_PATH.unshift(File.dirname(FILE))
        $LOAD_PATH.unshift File.join(File.dirname(FILE), 'lib')
        $LOAD_PATH.unshift File.join(File.dirname(FILE), 'lib', 'chunky_png')

      require 'chunky_png'

      Creating an image from scratch, save as an interlaced PNG

      png = ChunkyPNG::Image.new(201, 201, ChunkyPNG::Color::TRANSPARENT)
      for y in 0..200
      for x in 1..200
      png[x,y] = ChunkyPNG::Color.rgba(x, y, 0, 255)
      end
      end
      png.save('c:/TMP/testChunky_pngFile.png', :interlace => true)
      puts "Image saved"

      2a. The first error message is :
      load "C:/TMP/PNG_TEST/pngTest.rb"
      $LOAD_PATH: C:/TMP/PNG_TEST/lib/chunky_pngC:/TMP/PNG_TEST/libC:/TMP/PNG_TESTC:/Program Files (x86)/Google/Google SketchUp 8/Plugins/ProgressBar/squall/classC:/Program Files (x86)/Google/Google SketchUp 8/PluginsC:/Program Files (x86)/Google/Google SketchUp 8/PluginsC:/Program Files (x86)/Google/Google SketchUp 8/Tools
      Error: #<LoadError: C:/TMP/PNG_TEST/lib/chunky_png/chunky_png.rb:2:in require': no such file to load -- set> C:/TMP/PNG_TEST/pngTest.rb:7 C:/TMP/PNG_TEST/lib/chunky_png/chunky_png.rb:2 C:/TMP/PNG_TEST/pngTest.rb:7:in require'
      C:/TMP/PNG_TEST/pngTest.rb:7
      (eval):55:in `load'
      (eval):55

      2a. If I add the "standard ruby" set.rb class into the path a second eror message appears
      load "C:/TMP/PNG_TEST/pngTest.rb"
      $LOAD_PATH: C:/TMP/PNG_TEST/lib/chunky_pngC:/TMP/PNG_TEST/libC:/TMP/PNG_TESTC:/TMP/PNG_TEST/lib/chunky_pngC:/TMP/PNG_TEST/libC:/TMP/PNG_TESTC:/Program Files (x86)/Google/Google SketchUp 8/Plugins/ProgressBar/squall/classC:/Program Files (x86)/Google/Google SketchUp 8/PluginsC:/Program Files (x86)/Google/Google SketchUp 8/PluginsC:/Program Files (x86)/Google/Google SketchUp 8/Tools
      Error: #<NoMethodError: undefined method best_color_settings' for #<Set: {4278190335, 0, 16711935, 64255}>> C:/TMP/PNG_TEST/lib/chunky_png/canvas/png_encoding.rb:125 C:/TMP/PNG_TEST/lib/chunky_png/canvas/png_encoding.rb:75:in to_datastream'
      C:/TMP/PNG_TEST/lib/chunky_png/image.rb:62:in to_datastream' C:/TMP/PNG_TEST/lib/chunky_png/canvas/png_encoding.rb:35:in write'
      C:/TMP/PNG_TEST/lib/chunky_png/canvas/png_encoding.rb:43:in save' C:/TMP/PNG_TEST/lib/chunky_png/canvas/png_encoding.rb:43:in open'
      C:/TMP/PNG_TEST/lib/chunky_png/canvas/png_encoding.rb:43:in save' C:/TMP/PNG_TEST/pngTest.rb:30 (eval):7:in load'
      (eval):7

      1. The following "dirty patch" (here attached) works well:
        a. Duplicate "set.rb" file from "standard ruby 1.8.6". Rename it "set_bis.rb"
        b. In this new file "set_bis", rename classes "Set" and "SortedSet" into "Set_bis" and "SortedSet_bis"
        c. Change require 'Set' to require 'Set_bis' into chunky_png.rb
        d. Rename "Set" and "SortedSet" calls into "Palette.rb". These calls became "Set_bis" and "SortedSet_bis"

      Note: The following ressources also need to be in the load path.

      • enumerator.so
      • stringio.so
      • zlib.so
      • bibliothèque zlib

      chunkyPng_bis.zip

      posted in Developers' Forum
      L
      LFloissac
    • RE: Plugin to create a progress bar

      Thanks, it was a path "/Plugins/ProgressBar/html" problem.
      It works now !

      posted in Plugins
      L
      LFloissac
    • RE: Plugin to create a progress bar

      Hi Gregory,

      "Félicitations" (I'm French too) for your plugin.

      I'm using SU Pro - 8.0.14346 and your plugin ProgressBar v1.29
      I've tried to use your plugin and obtain the following message: "Run aborted. Error: progress_bar.rb:48:in `set_file': can't convert nil into String"
      the code used to call the plugin is from your example (see above). Do you have a suggestion ?

      require 'progress_bar.rb'

      pb = Squall::ProgressBar.new(200);
      pb.onCancel() {puts "cancel"};
      pb.process() {
      i = 0;
      loop{
      pb.progress();
      i += 1;
      break if(i == 200);
      sleep(0.5)
      };
      };

      posted in Plugins
      L
      LFloissac
    • 1 / 1