• Login
sketchucation logo sketchucation
  • Login
⌛ Sale Ending | 30% Off Profile Builder 4 ends 30th September

2 issues; inheritance & require ?

Scheduled Pinned Locked Moved Developers' Forum
10 Posts 3 Posters 205 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.
  • T Offline
    tomot
    last edited by 24 Aug 2011, 18:24

    I just did a new install of SU an a Netbook to check if a ruby I'm writing will work correctly.

    =begin
    # Name ; tool
    =end
    require 'sketchup.rb'
    require 'linetool.rb'
    
    class WallSectionTool < LineTool
    

    I found linetool.rb was not by default in the plugins dir rather in the Examples dir hence my ruby would not run. It did run when I moved linetool.rb to the plugins dir.
    Which makes me wonder if inheritance in Ruby of the Linetool is still a valid option?

    commenting out, I thought would cause my script not to run .... but it did!...why?

    #require 'sketchup.rb'
    #require 'linetool.rb'
    

    [my plugins](http://thingsvirtual.blogspot.ca/)
    tomot

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 24 Aug 2011, 18:29

      Perhaps other code already required them ?
      require 'linetool.rb'
      could be also
      require 'examples/linetool.rb'???

      TIG

      1 Reply Last reply Reply Quote 0
      • D Offline
        Dan Rathbun
        last edited by 24 Aug 2011, 18:55

        Yes don't move files from the "Examples" dir.

        The reason you did not need the require() statements, in the second case, was that Sketchup loads ALL files in the "Plugins" dir at startup.

        The Examples are ONLY loaded, if the user checks the option, in Window > Preferences > Extensions.

        OK ? so... Those files are "examples".. NOT Library files.

        1. The LineTool class does not belong at the toplevel !!1. Cut and paste the code into your OWN module, and modify / rename the class name.
        • like: class Tomot::LineTool1. then inherit from YOUR copy

        • like: class Tomot::WallSectionTool < Tomot::LineTool

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomot
          last edited by 24 Aug 2011, 21:15

          @tig said:

          Perhaps other code already required them ?
          require 'linetool.rb'
          could be also
          require 'examples/linetool.rb'???

          I was looking at some example code for a ruby written by RickW dated 2005 called parking .rb, perhaps back then linetool.rb was residing in the plugins dir however your require 'examples/linetool.rb' works!

          There is also something quite insidious in the Windows 7 OS, its the VirtualStore dir, which keeps files that are never uninstalled by the uninstall program process, also the latest save version remains there, while the unaltered version remains in c:\ProgramFiles\ Google\GoogleSketchUp8\Plugins

          You will find the virtual store dir: c:\UsersYour name\AppData\Local\VirtualStore
          Its only after the uninstall and deleting any left over files in both of these dir's that you have done a complete uninstall.

          [my plugins](http://thingsvirtual.blogspot.ca/)
          tomot

          1 Reply Last reply Reply Quote 0
          • D Offline
            Dan Rathbun
            last edited by 24 Aug 2011, 21:29

            Yes... the security on Win 6+ if a pain!

            Even a User cannot see his own AppData folders without going thru several confusing nested dialogs.

            THIS ISSUE is why users should be smart, and install their plugins to a directory that THEY control.

            I have my plugins in:
            "C:/Users/#{ENV['USERNAME']}/Documents/Google Sketchup/Common/Plugins"
            or
            "C:/Users/#{ENV['USERNAME']}/Documents/Google Sketchup/Sketchup ${Sketchup.version.to_i}/Plugins"

            see this code post: [Code] !autoload.rb loads "!_autoload" folders - v1.1.0

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • T Offline
              tomot
              last edited by 24 Aug 2011, 21:32

              @dan rathbun said:

              Cut and paste the code into your OWN module, and modify / rename the class name.

              • like: class Tomot::LineTool[*]then inherit from YOUR copy

              • like: class Tomot::WallSectionTool < Tomot::LineTool[/list]

              The Module stuff is still on my do list! 👍 Yes I did the reverse, I felt since there was no additional information I wanted to convey to the user, using the inheritance of the linetool.rb was adequate, hence I cut all linetool stuff out of my script.

              [my plugins](http://thingsvirtual.blogspot.ca/)
              tomot

              1 Reply Last reply Reply Quote 0
              • T Offline
                tomot
                last edited by 24 Aug 2011, 21:57

                I have not played around with that for a few years now: and I don't know if its still possible under Win 7 OS. I used to install each program I used to another totally independent HDD. such as drive e:/sketchup.
                I would never use the default offered by the installer. It was also a lot faster to make a bootable backup HDD, while all my programs and data still ran from my HDD drive e: and could not be accessed by a hacker.
                Unfortunately some addons today wont run anywhere else than from c:\Program Files

                [my plugins](http://thingsvirtual.blogspot.ca/)
                tomot

                1 Reply Last reply Reply Quote 0
                • D Offline
                  Dan Rathbun
                  last edited by 24 Aug 2011, 22:02

                  @tomot said:

                  Unfortunately some addons today wont run anywhere else than from c:\Program Files

                  That's not your fault.. it's the fault of the plugin author.

                  If they are not scrambled, you can tweak them... if they are, you can try to ask the author to fix the plugin.

                  I'm not here much anymore.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    Dan Rathbun
                    last edited by 24 Aug 2011, 22:04

                    @tomot said:

                    The Module stuff is still on my do list!

                    Really... it's not that hard.. and you will be much better off having all you code running within your protected namespace.

                    I'm not here much anymore.

                    1 Reply Last reply Reply Quote 0
                    • T Offline
                      tomot
                      last edited by 24 Aug 2011, 22:39

                      @dan rathbun said:

                      @tomot said:

                      Unfortunately some addons today wont run anywhere else than from c:\Program Files

                      That's not your fault.. it's the fault of the plugin author.

                      If they are not scrambled, you can tweak them... if they are, you can try to ask the author to fix the plugin.

                      A friend of mine recently said " if I want an appliance I'll buy a MAC if I want a computer I'll buy a PC. I think Microsoft is heading down the same road as Apple. A pay for everything, the user wants, freeway!

                      So I saved $350.00 by NOT having Apple install a new HDD, on my wife's iMac, I did it my way!


                      imac.jpg

                      [my plugins](http://thingsvirtual.blogspot.ca/)
                      tomot

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

                      Advertisement