SketchUcation Plugin Store

 

 

Review of Plugin/NameSpace/Extension Format

Review of Plugin/NameSpace/Extension Format

Postby ktkoh » Fri Aug 10, 2012 5:35 pm

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
Please, register (free) to access all the attachments on the forums.
Last edited by ktkoh on Fri Aug 10, 2012 9:49 pm, edited 1 time in total.
ktkoh
 
Posts: 147
Joined: Mon Mar 31, 2008 1:40 am
Location: Bellefontaine OH
Name: Keith Krueger
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: woodworking
Level of SketchUp: Intermediate

Re: Review of Plugin/NameSpace/Extension Format

Postby thomthom » Fri Aug 10, 2012 8:13 pm

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
User avatar
thomthom
Global Moderator
 
Posts: 17545
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: thomthom
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: Review of Plugin/NameSpace/Extension Format

Postby ktkoh » Fri Aug 10, 2012 11:26 pm

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
ktkoh
 
Posts: 147
Joined: Mon Mar 31, 2008 1:40 am
Location: Bellefontaine OH
Name: Keith Krueger
Operating system: Windows
SketchUp version: 8
License type: Free
SketchUp use: woodworking
Level of SketchUp: Intermediate

Re: Review of Plugin/NameSpace/Extension Format

Postby Dan Rathbun » Sat Aug 11, 2012 6:30 am

    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"
    Code: Select all
    # 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.
    User avatar
    Dan Rathbun
    Top SketchUcator
     
    Posts: 4069
    Joined: Tue Oct 06, 2009 3:06 am
    Location: Florida, USA
    Name: Dan Rathbun
    Operating system: Windows
    SketchUp version: 8
    License type: Pro
    SketchUp use: education
    Level of SketchUp: Advanced

    Re: Review of Plugin/NameSpace/Extension Format

    Postby ktkoh » Sat Aug 11, 2012 1:15 pm

    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
    ktkoh
     
    Posts: 147
    Joined: Mon Mar 31, 2008 1:40 am
    Location: Bellefontaine OH
    Name: Keith Krueger
    Operating system: Windows
    SketchUp version: 8
    License type: Free
    SketchUp use: woodworking
    Level of SketchUp: Intermediate

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago

    Not a Premium Member yet? Check out the great time-limited deal we are offering.

    Ad Machine
    Robot
     
    Posts: 2012



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 3 guests