• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Functions in 'require' are not updated till restart..

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 219 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.
  • R Offline
    ruggiero.guida
    last edited by 14 Jul 2014, 08:50

    Dear Forum,

    I am developing a ruby script for shading calculations to integrate with my CFD analysis.

    I have a few functions within an external file (not in a module) that I include in the main code with 'require'.

    It has been working fine for the last few weeks, but a couple of days ago, I noticed that if I made a change in one of these external functions, these changes were not 'seen' until I restarted skethcup. The function worked once copied directly in the main script and I confirmed that the file was actually saved.

    Is there any specific directive that I have to use at the beginning of the main ruby script? Is it a name space issue? I will keep testing, but it would be good to understand what it is actually happening.

    This is what I have at the beginning of my code

    require 'sketchup.rb'
    require 'r/ReadMesh.rb'
    #require 'r/ReadCSVMesh.rb'
    require 'yaml'
    require 'csv'
    require 'r/readCSV'
    include Math

    ReadCSVMesh is the function incriminated...

    Thanks a lot

    1 Reply Last reply Reply Quote 0
    • T Offline
      tt_su
      last edited by 14 Jul 2014, 09:20

      require will ensure that a file is loaded only once. It will not update automatically. If you need to reload while developing you can reload the file using the Ruby console and the load method.

      1 Reply Last reply Reply Quote 0
      • R Offline
        ruggiero.guida
        last edited by 14 Jul 2014, 12:45

        Thanks. Trying to make my head around modules. I am not planning to write plugins for distribution, I am just trying to keep my code cleaner.

        Cheers

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 14 Jul 2014, 19:23

          You should NOT be including ANY module like Math into the global objectspace, which is actually class Object. Everyone else's classes and modules will then inherit any change YOU make to the global objectspace!

          It does not matter whether you will be distributing or not. There is a right way to code.
          It is more about not corrupting other people's plugins.

          There is NO reason whatever for you to run code outside YOUR OWN module namespace.
          So pick a unique toplevel module name, like Guida or RG or whatever, and then define ALL your plugins as sub-modules of YOUR toplevel modulespace. Within each plugin module, define nested modules and / or classes, as needed by each plugin.

          I'm not here much anymore.

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

          Advertisement