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

    Will NOT scramble ??

    Scheduled Pinned Locked Moved Developers' Forum
    44 Posts 4 Posters 1.4k 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.
    • K Offline
      ksor
      last edited by

      @thomthom said:

      @ksor said:

      The "A" never comes up 😠 😠 😠 - maybe the scrambler IS a prototype - then just say it then.

      So when you do tried Polley.new nothing happened - no error at all?

      Your example didn't include anything about how you tested it - maybe there is something there.

      I just did the same as with the .rb file - just clicked in the menu: when run by .rb the "A" comes up, when run as .rbs nothing happens - no error, nothing at all.

      I never used so much time on so little code with so little outcome - it feels like just killing time !

      Best regards
      KSor, Denmark
      Skype: keldsor

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @ksor said:

        I just did the same as with the .rb file - just clicked in the menu: when run by .rb the "A" comes up, when run as .rbs nothing happens - no error, nothing at all.

        There is something else going on. I tried that Polley snippet you posted - scrambled it. Loaded the .rbs and wrote in the console: x=Polley.new
        The messagebox popped up.

        Did you try exactly that small snippet yourself - or did you extract it from your main code? Sounds like your issues lies with the construct of your plugin.

        Since you don't get any messagebox, nor any errors when it should pop up it sound like something is overriding the initialize method.
        (Remember you cannot reload a .rbs - you must restart SketchUp to see any changes.)

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

        1 Reply Last reply Reply Quote 0
        • K Offline
          ksor
          last edited by

          @thomthom said:

          @ksor said:

          I just did the same as with the .rb file - just clicked in the menu: when run by .rb the "A" comes up, when run as .rbs nothing happens - no error, nothing at all.

          There is something else going on. I tried that Polley snippet you posted - scrambled it. Loaded the .rbs and wrote in the console: x=Polley.new
          The messagebox popped up.

          Did you try exactly that small snippet yourself - or did you extract it from your main code? Sounds like your issues lies with the construct of your plugin.

          Since you don't get any messagebox, nor any errors when it should pop up it sound like something is overriding the initialize method.
          (Remember you cannot reload a .rbs - you must restart SketchUp to see any changes.)

          I did EXACTLY that snippet af code - and I start SketchUp from scratch each time I do some tests.

          I start it as an extension as recommended and this primary code is here:

          require 'sketchup.rb'
          require 'extensions.rb'
          
          filename=File.basename(__FILE__)
          if(not file_loaded?(filename))
              UI.menu("Plugins").add_item("Remskive") { Sketchup.active_model.select_tool Polley.new }
          end
          file_loaded(filename)
            
          # Create the extension.
          ext = SketchupExtension.new 'Remskive', 'Remskive/Remskive_LOADER'
          
          # Attach some nice info.
          ext.creator     = 'Keld Sørensen, Danmark'
          ext.version     = '1.0.0'
          ext.copyright   = '2012..., Keld Sørensen'
          ext.description = 'Visit my website; http://kelds.weebly.com/udvidelser.html'
          
          # Register and load the extension on startup.
          Sketchup.register_extension ext, true
            
          
          
          

          Best regards
          KSor, Denmark
          Skype: keldsor

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @ksor said:

            I did EXACTLY that snippet af code - and I start SketchUp from scratch each time I do some tests.

            I start it as an extension as recommended and this primary code is here:

            Did you read my previous comment about namespace and loading scrambled files via SketchupExtension?

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

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              On a sidenote - it can be confusing for the user if the menus are always there - regardless if the extension is loaded. And it'd defeat the purpose of using the extension. Menus should be loaded by the script that SketchupExtension loads.

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

              1 Reply Last reply Reply Quote 0
              • K Offline
                ksor
                last edited by

                @thomthom said:

                On a sidenote - it can be confusing for the user if the menus are always there - regardless if the extension is loaded. And it'd defeat the purpose of using the extension. Menus should be loaded by the script that SketchupExtension loads.

                ????
                Maybe I misunderstands you - english isn't my first language 😄 - but isn't exactly the opposit of what TIG told me to do ?

                Best regards
                KSor, Denmark
                Skype: keldsor

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  @ksor said:

                  @thomthom said:

                  On a sidenote - it can be confusing for the user if the menus are always there - regardless if the extension is loaded. And it'd defeat the purpose of using the extension. Menus should be loaded by the script that SketchupExtension loads.

                  ????
                  Maybe I misunderstands you - english isn't my first language 😄 - but isn't exactly the opposit of what TIG told me to do ?

                  Not quite.

                  The general structure is:

                  Plugins/plugin.rb
                  Defines the SketchupExtension and maybe some constants containing the path of the plugin which the scrambled files can later use.
                  The extension loads Plugins/MyPlugin/loader.rb

                  Plugins/MyPlugin/loader.rb
                  Loads the rest of the .rbs files. You can define the menus here as well.
                  This proxy unscrambled .rbs file ensures that the content of the rbs files doesn't end up under the SketchupExtension namespace.
                  Putting the menus there also ensures they are not cluttering the UI while the extension is disabled.

                  If the .rbs files need to address the path where the plugin is located they would then refer to the path constant previously defined - withing your own namespace of course.

                  Was that outline somewhat clear?


                  Engelsk er ikke mitt første språk heller. 😉 (Men jeg bodde der i fire år...)

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

                  1 Reply Last reply Reply Quote 0
                  • K Offline
                    ksor
                    last edited by

                    thomthom

                    I think so - but how to implement it if it should NOT be done like I did BEFORE and AFTER TIG made me move my menu settings from/to the primary .rb-file - do you have some sample code ?

                    Best regards
                    KSor, Denmark
                    Skype: keldsor

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Plugins/foobar.rb

                      <span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /></span><span class="syntaxdefault">require </span><span class="syntaxstring">'extensions.rb'<br /><br /><br /></span><span class="syntaxdefault">module Author<br />  module PluginName<br />  <br />  </span><span class="syntaxcomment"># Constants<br /></span><span class="syntaxdefault">  PATH </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> __FILE__ </span><span class="syntaxkeyword">),</span><span class="syntaxdefault"> </span><span class="syntaxstring">'PluginSupportFolder'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">).</span><span class="syntaxdefault">freeze<br />  <br />  </span><span class="syntaxcomment"># Extension<br /></span><span class="syntaxdefault">  loader </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'loader.rb'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  ex </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> SketchupExtension</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Hello Scrambled World'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> loader </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">description </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Lorem Ipsum"<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'1.0.0'<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">copyright </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'John Smith © 2012'<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">creator </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'John Smith (john@example.com)'<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">register_extension</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> true </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault">  end </span><span class="syntaxcomment"># module PluginName<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># module Author  &nbsp;</span><span class="syntaxdefault"></span>
                      

                      Plugins/PluginSupportFolder/loader.rb

                      <span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /><br /><br /></span><span class="syntaxdefault">module Author<br />  module PluginName<br />  <br />  </span><span class="syntaxcomment"># Menus and Toolbars<br /></span><span class="syntaxdefault">  unless file_loaded</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    m </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Plugins'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    m</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">...</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  end<br />  <br />  </span><span class="syntaxcomment"># Load the rest of the files - which might be scrambled.<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file1'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file2'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file3'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault">  end </span><span class="syntaxcomment"># module PluginName<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># module Author<br /><br /></span><span class="syntaxdefault">file_loaded</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span>
                      

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

                      1 Reply Last reply Reply Quote 0
                      • K Offline
                        ksor
                        last edited by

                        Thx - thomthom, I'll study the code carefully !

                        Best regards
                        KSor, Denmark
                        Skype: keldsor

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

                          @ksor said:

                          @tig said:

                          The Ruby __FILE__ won't work inside a compiled .rbs file, so that's probably breaking it.

                          Something is not right here - you say the " __FILE__" won't wotk in .rbs files - NOT TRUE !

                          [removed 2 code samples - #1 loads OK then #2 does not work after #1 loads]

                          ... i can't see the principal difference: Can someone pleace tell me why ?

                          SIMPLE ANSWER (TIG said this, but not so basic...)

                          In RBS file #1: __FILE__ returns "(eval)" and file_loaded() pushes it onto the $loaded_files array.

                          When RBS file #2 loads: It uses file_loaded?() to check the $loaded_files array for the value of __FILE__ (which during evaluation of a scrambled script == "(eval)",) AND the value is already found in the array,

                          .. SO those conditional blocks for ANY RBS file, that you load AFTER file #1, will not create the menu items.

                          I'm not here much anymore.

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

                            On MS Windows...

                            You can scramble files from the GUI without opening a cmd shell.

                            Just drag and drop an rb file (from Explorer window 1,) ONTO scrambler.exe (in another Explorer window.)

                            .. and the rbs file will be put in the original folder with it's rb file.

                            This may also work with a shortcut icon for scrambler.exe ??

                            • This works great on XP, Windows 6+ users need to have write permissions the destination folder.

                            I'm not here much anymore.

                            1 Reply Last reply Reply Quote 0
                            • K Offline
                              ksor
                              last edited by

                              @dan rathbun said:

                              On MS Windows...

                              You can scramble files from the GUI without opening a cmd shell.

                              Just drag and drop an rb file (from Explorer window 1,) ONTO scrambler.exe (in another Explorer window.)

                              .. and the rbs file will be put in the original folder with it's rb file.

                              This may also work with a shortcut icon for scrambler.exe ??

                              • This works great on XP, Windows 6+ users need to have write permissions the destination folder.

                              Oh ... Dan, that was a good one - thx !

                              I'll implement it right away !

                              Best regards
                              KSor, Denmark
                              Skype: keldsor

                              1 Reply Last reply Reply Quote 0
                              • K Offline
                                ksor
                                last edited by

                                @dan rathbun said:

                                This may also work with a shortcut icon for scrambler.exe ??

                                It WORKS fine with the shortcut too - really great Dan !

                                Best regards
                                KSor, Denmark
                                Skype: keldsor

                                1 Reply Last reply Reply Quote 0
                                • K Offline
                                  ksor
                                  last edited by

                                  @thomthom said:

                                  Plugins/foobar.rb

                                  <span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /></span><span class="syntaxdefault">require </span><span class="syntaxstring">'extensions.rb'<br /><br /><br /></span><span class="syntaxdefault">module Author<br />  module PluginName<br />  <br />  </span><span class="syntaxcomment"># Constants<br /></span><span class="syntaxdefault">  PATH </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> __FILE__ </span><span class="syntaxkeyword">),</span><span class="syntaxdefault"> </span><span class="syntaxstring">'PluginSupportFolder'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">).</span><span class="syntaxdefault">freeze<br />  <br />  </span><span class="syntaxcomment"># Extension<br /></span><span class="syntaxdefault">  loader </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'loader.rb'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  ex </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> SketchupExtension</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Hello Scrambled World'</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> loader </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">description </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Lorem Ipsum"<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'1.0.0'<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">copyright </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'John Smith © 2012'<br /></span><span class="syntaxdefault">  ex</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">creator </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'John Smith (john@example.com)'<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">register_extension</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> ex</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> true </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault">  end </span><span class="syntaxcomment"># module PluginName<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># module Author     &nbsp;</span><span class="syntaxdefault"></span>
                                  

                                  Plugins/PluginSupportFolder/loader.rb

                                  <span class="syntaxdefault">require </span><span class="syntaxstring">'sketchup.rb'<br /><br /><br /></span><span class="syntaxdefault">module Author<br />  module PluginName<br />  <br />  </span><span class="syntaxcomment"># Menus and Toolbars<br /></span><span class="syntaxdefault">  unless file_loaded</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    m </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Plugins'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    m</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">...</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  end<br />  <br />  </span><span class="syntaxcomment"># Load the rest of the files - which might be scrambled.<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file1'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file2'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">'file3'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault">  end </span><span class="syntaxcomment"># module PluginName<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># module Author<br /><br /></span><span class="syntaxdefault">file_loaded</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">basename</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span>
                                  

                                  Sorry, but I still don't understand - are the two code samples two alternatives or ONE way to do WHAT ?

                                  In the second code you have "PluginName" - what is that compared to the items under the Plugin menu ?
                                  and what is it compared to the "the rest of the files" ... file1, file2 and file 3 ?

                                  How are the folder structure - should ALL my .rb and .rbs files be store in the PluginSupportFolder ?

                                  Are "loader.rb" a peace of code that load ALL my plugins under the menu "Plugins" or .. ?

                                  Please give me some overview of the structure.

                                  I get this error message when running SketchUp:

                                  Error Loading File C:/Program Files/Google/Google SketchUp 8/Plugins/PluginSupportFolder/loader.rb
                                  tried to create Proc object without a blockError Loading File Foobar.rb
                                  tried to create Proc object without a block

                                  Best regards
                                  KSor, Denmark
                                  Skype: keldsor

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

                                    You have a script xxx.rb file that is placed in the Plugins folder.
                                    this file will then auto-load/run, and thereby it creates an Extension.
                                    It also sets /tool_folder/yyy.rb to be loaded IF the Extension is active, but not otherwise.
                                    The /tool_folder/yyy.rb file is a 'loader' script.
                                    It does not auto-load/run because it's in the subfolder - but it is activated from the xxx.rb file that itself loads from Plugins, IF the specified Extension is active...
                                    When loaded the yyy.rb file will create, menus, submenus, context-menus and toolbars... AND it loads the file[s] /tool_folder/aaa.RBS etc - which are your files containing the main code for your tool[s].
                                    RBS files are compiled but IF you are not compiling them they will simply end in .RB and will be human-readable...
                                    The Plugins subfolder, referred to above as 'tool_folder', is your own subfolder in Plugins; and inside which you package your main tools' files.
                                    It can be a single user named subfolder with more subfolders for each tool - e.g. then you'd use Plugins/KSOR_tools_folder/tool_aaa/yyy.rb - or it can be a tool-specific folder like Plugins/KSOR_tool_aaa/yyy.rb - you choose...
                                    This subfolder [or its subfolders] can also contain any images needed for toolbar-buttons and the many files used to make webdialogs etc...

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • K Offline
                                      ksor
                                      last edited by

                                      @tig said:

                                      You have a script xxx.rb file that is placed in the Plugins folder.
                                      this file will then auto-load/run, and thereby it creates an Extension.
                                      It also sets /tool_folder/yyy.rb to be loaded IF the Extension is active, but not otherwise.
                                      The /tool_folder/yyy.rb file is a 'loader' script.
                                      It does not auto-load/run because it's in the subfolder - but it is activated from the xxx.rb file that itself loads from Plugins, IF the specified Extension is active...
                                      When loaded the yyy.rb file will create, menus, submenus, context-menus and toolbars... AND it loads the file[s] /tool_folder/aaa.RBS etc - which are your files containing the main code for your tool[s].
                                      RBS files are compiled but IF you are not compiling them they will simply end in .RB and will be human-readable...
                                      The Plugins subfolder, referred to above as 'tool_folder', is your own subfolder in Plugins; and inside which you package your main tools' files.
                                      It can be a single user named subfolder with more subfolders for each tool - e.g. then you'd use Plugins/KSOR_tools_folder/tool_aaa/yyy.rb - or it can be a tool-specific folder like Plugins/KSOR_tool_aaa/yyy.rb - you choose...
                                      This subfolder [or its subfolders] can also contain any images needed for toolbar-buttons and the many files used to make webdialogs etc...

                                      A good one - I'll try to get the structure set up - but a little fire was started in the end and a little smoke came up ... ha, ha !

                                      Best regards
                                      KSor, Denmark
                                      Skype: keldsor

                                      1 Reply Last reply Reply Quote 0
                                      • K Offline
                                        ksor
                                        last edited by

                                        This code samples sucks more and more of just killing time !

                                        Now I can't use the danish special signs æøåÆØÅ instide a string without fooling the interpretor !

                                        I get very, very tired when things like tha tcomes up ... Zzz ZZ ZZZZZ yawning .... prusssssss

                                        Best regards
                                        KSor, Denmark
                                        Skype: keldsor

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

                                          @ksor said:

                                          Sorry, but I still don't understand - are the two code samples two alternatives or ONE way to do WHAT ?

                                          ONE way to define a SketchupExtension class compatible plugin.

                                          ThomThom's example was (an incomplete,) short version, of my longer, more verbose, lesson that you can find here:
                                          [ Code ] SketchupExtension and rbs rubies


                                          It is not necessary to completely quote large code blocks.. you can can reference them using a [ url ] bbCode tag (like I did above.)


                                          The error you are getting.. is because it was an incomplete sample, and was missing the menu_item **{** ... **}** code block, on line 10, of the "loader.rb" sample.

                                          He never intended you to try and load those files as is. He expected you to modify them to use with REAL module names, and REAL file names.

                                          Whenever you see a module name "Author", you are expected to replace that with YOUR OWN TOPLEVEL AUTHOR module name.

                                          Whenever you see a submodule "Plugin..." name, you are expected to replace that with YOUR OWN SPECIFIC PLUGIN submodule name.

                                          💭

                                          I'm not here much anymore.

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

                                            @ksor said:

                                            Now I can't use the danish special signs æøåÆØÅ instide a string without fooling the interpretor !

                                            Are you saying that UTF-8 characters do not work inside scrambled rubies ???

                                            Did you save your unscrambled rb file as "UTF-8 without BOM" (aka "ANSI as UTF-8"), before scrambling ???

                                            I'm not here much anymore.

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

                                            Advertisement