sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Sketchup.load

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 4 Posters 298 Views 4 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.
    • Al HartA Offline
      Al Hart
      last edited by

      I am feeling pretty dumb this afternoon.

      I have a ruby which looks like this:

      printf("test.rb")

      When I start SketchUp 2014 and load it, I get this:
      (it is stored in c:\aa)

      Sketchup.load('c:/aa/test.rb') test.rb true

      If I try it again, I get this:

      Sketchup.load('c:/aa/test.rb') false

      Is there some new, (or perhaps even old), logic that only loads a ruby once?

      If I use just load, it loads fine:

      ` load('c:/aa/test.rb')
      test.rb
      true

      load('c:/aa/test.rb')
      test.rb
      true`

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • Al HartA Offline
        Al Hart
        last edited by

        If we are not using .rbs, is there any reason to use Sketchup.load rather than just load?

        Al Hart

        http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
        IRender nXt from Render Plus

        1 Reply Last reply Reply Quote 0
        • Al HartA Offline
          Al Hart
          last edited by

          I see this note on the Google SketchUp forum:

          *[pre:jdmy8csy]"Sketchup.load behaves just like Sketchup.require.

          I just wanted to make note in case anyone was expecting Sketchup.load
          to behave the same as its Ruby equivalent."[/pre:jdmy8csy]*

          Could that be true?

          Al Hart

          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
          IRender nXt from Render Plus

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            The current docs for Sketchup#require:
            http://www.sketchup.com/intl/en/developer/docs/ourdoc/sketchup?csw=1#require

            This is an alias of the Sketchup.load method.

            Although because of the behavior, I suspect Sketchup#load is the alias for Sketchup#require, and the docs are incorrect.

            Hi

            1 Reply Last reply Reply Quote 0
            • Al HartA Offline
              Al Hart
              last edited by

              Either way it is a confusion.

              We use "require" when we only want to load something once - and are prepared to exit and restart SketchUp if we want to change something an load it again.

              But, especially when debugging our code, we want to use 'load' to reload a ruby which we are debugging without having to exit and restart SketchUp. (Perhaps we should reload it, but it is awfully convenient to be able to reload a ruby and test it on the fly)

              Because we incorrectly assumed that Sketchup.load() and load() were identical, except for the processing of .rbs files, SketchUp.load() occasionally slipped into something which would have worked with load.

              Ah, but C'est la Vie - it is too late now for SketchUp to make load and require operated differently, and more in keeping with Ruby load and require. So we'll just have to be more careful to use just load().


              Al Hart

              http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
              IRender nXt from Render Plus

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                You could test using the unscrambled file, then load would work as expected.

                Hi

                1 Reply Last reply Reply Quote 0
                • tt_suT Offline
                  tt_su
                  last edited by

                  Yea, it's an annoying deviance that Sketchup::load acts like Sketchup::require.

                  For my personal projects I got reload code for when testing RBS files where I remove the file from the $LOADED_FEATURES list.

                  1 Reply Last reply Reply Quote 0
                  • Dan RathbunD Offline
                    Dan Rathbun
                    last edited by

                    @al hart said:

                    Ah, but C'est la Vie - it is too late now for SketchUp to make load and require operated differently, and more in keeping with Ruby load and require.

                    I totally disagree and always will.

                    If it is wrong, fix it make it correct, at the first best opportunity.

                    With this release using Ruby 2.0, was the perfect time to fix it so that developers could check their code, and update it at the same time they fixed other things that needed fixing for Ruby 2.x.

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • Al HartA Offline
                      Al Hart
                      last edited by

                      @jim said:

                      You could test using the unscrambled file, then load would work as expected.

                      I don't think Sketchup.load ever works as expected.

                      I expected it to load the .rb or .rbs, even if I had already loaded it before.

                      What it does is quietly "not load" it if it has been loaded already.

                      Al Hart

                      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                      IRender nXt from Render Plus

                      1 Reply Last reply Reply Quote 0
                      • Al HartA Offline
                        Al Hart
                        last edited by

                        @dan rathbun said:

                        I totally disagree and always will.

                        If it is wrong, fix it make it correct, at the first best opportunity.

                        With this release using Ruby 2.0, was the perfect time to fix it so that developers could check their code, and update it at the same time they fixed other things that needed fixing for Ruby 2.x.

                        You are right Dan. This release would have been a great time to fix this, and we could all have looked through our code for calls to Sketchup.load() to anticipate problems.

                        Also, if Sketchup.load() always loaded things, rather than just the first time, if would almost never create a real problem. So they should just fix it now.

                        (It would "create a problem", if some one was changing .rb files on the fly, and then loading them with Sketchup.load and expecting that the would only load if they had not already been loaded. I suspect that no one is actually doing this. We do have code which creates ruby files on the fly, and then loads them - but we expect them to actually get loaded. [We wrote these as part of an early CAD System to SketchUp importer which created a ruby file of the geometry of the CAD System, and then loaded to ruby file to import the geometry.])

                        Al Hart

                        http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                        IRender nXt from Render Plus

                        1 Reply Last reply Reply Quote 0
                        • Al HartA Offline
                          Al Hart
                          last edited by

                          @tt_su said:

                          Yea, it's an annoying deviance that Sketchup::load acts like Sketchup::require.

                          For my personal projects I got reload code for when testing RBS files where I remove the file from the $LOADED_FEATURES list.

                          $LOADED_FEATURES - Aha! I didn't know about that. I guess you learn something ever day.

                          Al Hart

                          http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                          IRender nXt from Render Plus

                          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