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

    Review of Plugin/NameSpace/Extension Format

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 209 Views 3 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
      ktkoh
      last edited by ktkoh

      Several months ago I asked about plugin formating and Dan made a namespace template/example for me and now I have finally got a working plugin written using the template. I thought before I offered it to fellow woodworkers I would post it here for comments to see if I am using acceptable format so as not to cause problems with other plugins.

      Thanks for your help
      Keith


      Decription of Plugin


      K2WS_Comp2LayerScene_ext.rbz

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

        You're .rb file attached doesn't tell us anything about your namespacing. It refers to other files we cannot see.

        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
          ktkoh
          last edited by

          I edited my post with the correct file. You can either install as extension or change it to a zip file and unzip to see the files in question.

          Keith

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

            A minor change needed ...

            in file: "K2WS_Comp2LayerScene_ext.rb", lines 7 & 8 should not be at this place, in this file.
            (Because it will force a load of the "K2WS/k2ws_module.rb" file even when the user has turned OFF the plugin, via the Preferences dialog (Extensions panel.)

            Move those two lines, into the "K2WS/Comp2LayerScene/Comp2LayerScene.rb" file, just after (current) line 22, which is:
            require('sketchup.rb')

            This way.. it will only load, when the plugin is turned ON. (Many users are also developers, and they need to have the option of a "clean" and fast loading Ruby environment when testing/debugging.)


            The only other thing, is that if you need to get a reference "handle" on your plugin's SketchupExtension instance object, you cannot do it under SU7.x, unless you save it as a module var. This means wrapping the definition in file: "K2WS_Comp2LayerScene_ext.rb" within your plugin namespace. (Note that in SU 8.0M2 or higher, you can query the ExtensionsManager collection to find a certain SketchupExtension instance, if need be, but since you are creating it, you might as well retain a reference to it.)

            Ex: "K2WS_Comp2LayerScene_ext.rb"

            # Load the normal support files.
            require('sketchup.rb')
            require('extensions.rb')
              
            module K²WS; end
            module K²WS;;Comp2LayerScene
            
              # Create the extension.
              ext = SketchupExtension.new('K2WS (Component to Layer & Scene)',
                  'K2WS/Comp2LayerScene/Comp2LayerScene_loader.rb')
            
              # Keep a reference to it;
              @@plugin = ext
              
              # Attach some nice info.
              ext.creator     = 'Keith Krueger email kbkrueger2@gmail.com'
              ext.version     = '1.0.0' 
              ext.description = 'Layers & Scenes for Components & Dim'
              ext.copyright   = ''
            
              # Register and load the extension on startup.
              Sketchup.register_extension(ext, true)
            
            end # module K²WS;;Comp2LayerScene
            
            

            Also, would suggest putting something in the " copyright" attribute, to indicate the "Terms of Use": eaxmples: "(c)2012, Keith Krueger, All Rights Reserved", or "released under the Artistic License, 2.0", or "see GPL, version X.x", or "Public Domain" or ... whatever you decide.


            Note that future versions of Ruby will require that all method calls have parameter lists delimted by ( and ), so try to get in the habit of using them now. Especially if you do not want to have to go back through your old projects, and add them in later, when SketchUp begins using one of these newer Ruby versions.

            I'm not here much anymore.

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

              Thanks Dan for the review and changes. I have adjusted my files to include your suggestions and when I have a how to vidio completed I will post in the plugin section.

              Also I expect to be back for help on putting my Joint Tools under the namespace umbrella as I have just started that process.

              Keith

              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