sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Sketchup class load method

    Scheduled Pinned Locked Moved SketchUp Bug Reporting
    sketchup
    2 Posts 2 Posters 2.4k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ChiefwoodworkerC Offline
      Chiefwoodworker
      last edited by

      Hi guys,

      I believe there may be a bug (or incorrect implementation) with the Sketchup class load method. My understanding of the Sketchup class load method is that it is modeled after the Ruby Kernel load method but designed to handle scrambled files (.rbs) as well as non-scrambled files (.rb). The problem is that it doesn't seem to behave the same in that the Kernel.load method will load a .rb file even if it is already loaded - with the appropriate warnings - wereas the Sketchup.load method does not; even when executed from the Ruby console.

      For example:

      Kernel.load 'cabwriter_factory_settings.rb' results in

      C:/Users/Joe/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/cabwriter_factory_settings.rb:17: warning: already initialized constant CabWriterFactoryInitialize::NEW_PROJECT
      C:/Users/Joe/AppData/Roaming/SketchUp/SketchUp 2015/SketchUp/Plugins/cabwriter_factory_settings.rb:17: warning: previous definition of NEW_PROJECT was here
      true

      Whereas Sketchup.load 'cabwriter_factory_settings' results in

      false

      Am I missing something or is this a bug?

      Joe....
      http://www.srww.com

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        load "some_text_file_in_the_load_path"

        always returns true unless there is an error.

        require "some_text_file_in_the_load_path"

        only returns true if that file has never been loaded before during that session.

        Sketchup's own require and load are designed to work with text files [typically RB files] OR its specialized compiled RBS files,
        Oddly Sketchup::load is actually an alias of Sketchup::require - so both of them will return false if the file has been loaded before.
        So when testing use ' load' instead !
        Compile the RB to RBS if desired and use Sketchup's method to load it - only when you've debugged the code...

        TIG

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement