• Login
sketchucation logo sketchucation
  • Login
πŸ”Œ Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

Sketchup::load under different binding?

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 2 Posters 160 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.
  • T Offline
    thomthom
    last edited by 20 Aug 2012, 10:24

    Is it possible to use Sketchup::load from within a module, but have the loaded content evaled under the top level binding?

    I'm trying to load RBS files, but it all gets wrapped inside the current module.

    Thomas Thomassen β€” SketchUp Monkey & Coding addict
    List of my plugins and link to the CookieWare fund

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 20 Aug 2012, 11:55

      IS the RBS scrambled code itself namespace wrapped ??

      What if the rbs code looked like this using the top level scope operator:

      # I am a scrambled rbs file;
      
      ;;TT;;SubModuleName
      
        # code that belongs in ;;TT;;SubModuleName
      
      end
      

      IF the Mac's Ruby v1.8.5-p0 does not recognize the top level scope operator, then perhaps YOU force the namespace evaluation:

      # I am a scrambled rbs file;
      
      this_file = 'thisfilename.rbs'
      str = %q[
      TT;;SubModuleName
      
        # code that belongs in ;;TT;;SubModuleName
      
      end
      ]
      Kernel.eval( str, TOPLEVEL_BINDING, this_file, 4 )
      
      

      or maybe:

      # I am a scrambled rbs file;
      
      Object.class_eval {
      TT;;SubModuleName
      
        # code that belongs in ;;TT;;SubModuleName
      
      end
      }
      
      

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 20 Aug 2012, 12:14

        Any way to do this without modifying the content of the rbs?

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 20 Aug 2012, 12:25

          I remember you talking about this issue before.

          But I have never seen it myself.

          Did you ever post some simple barebones examples ??

          If I knew what you were really trying to do... perhaps PM me. (You already know I can be discrete.)

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 20 Aug 2012, 13:22

            @thomthom said:

            Any way to do this without modifying the content of the rbs?

            Hmm.. what about this:

            TT;;LoadManager
            
              # I am a namespace calling Sketchup.load;
             
              rbs_file = 'subdir/filename.rbs'
            
              # Evaluate the Sketchup.load() call within TOPLEVEL_BINDING;
              eval( "Sketchup;;load(#{rbs_file})", TOPLEVEL_BINDING, rbs_file, 1 )
             
            end # module TT;;LoadManager
            
            

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • T Offline
              thomthom
              last edited by 20 Aug 2012, 14:12

              @dan rathbun said:

              @thomthom said:

              Any way to do this without modifying the content of the rbs?

              Hmm.. what about this:

              TT;;LoadManager
              > 
              >   # I am a namespace calling Sketchup.load;
              >  
              >   rbs_file = 'subdir/filename.rbs'
              > 
              >   # Evaluate the Sketchup.load() call within TOPLEVEL_BINDING;
              >   eval( "Sketchup;;load(#{rbs_file})", TOPLEVEL_BINDING, rbs_file, 1 )
              >  
              > end # module TT;;LoadManager
              > 
              

              πŸ‘ πŸ‘

              That seem to work perfectly!

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • D Offline
                Dan Rathbun
                last edited by 20 Aug 2012, 14:19

                @thomthom said:

                That seem to work perfectly!

                Excellent!

                4 trys is the charm.

                Man, I love Ruby's flexibility!

                I'm not here much anymore.

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

                Advertisement