sketchucation logo sketchucation
    • Login
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Uninitialized constant

    Scheduled Pinned Locked Moved Developers' Forum
    12 Posts 3 Posters 2.2k 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.
    • TIGT Online
      TIG Moderator
      last edited by

      Try adding:
      Dir[path+'/rexml/parsers/'].each{|file|Sketchup::require file}
      This will load everything in that directory in case something else is missing...

      TIG

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

        @tig said:

        Try adding:
        Dir[path+'/rexml/parsers/'].each{|file|Sketchup::require file}
        This will load everything in that directory in case something else is missing...

        Or use the require_all call.

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

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

          Duh!
          Something like...
          Sketchup::require_all 'path+"/rexml/*/*.rb"'
          Which would load all '.rb' rubies in the '/parsers/' folder AND those in any othersub-folders too...

          TIG

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

            Don't think you need to prefix it with Sketchup::... I've only used it once, but I think I just used require_all.

            @tig said:

            AND those in any other sub-folders too...

            Really? I haven't found any other info on the method than this page: http://code.google.com/intl/nb/apis/sketchup/docs/loading.html

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

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

              I assumed the Sketchup:: was because it might get scrambled later ?
              The * wildcards .../*/*.rb process all folders in the path, and require the .rb files found ?

              TIG

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

                Ah,.. I don't know anything about scrambled files.

                I found this though on the sub folder topic: http://forums.sketchucation.com/viewtopic.php?f=15&t=16029&p=124772#p125137
                Maybe it does include subfolders.
                If so I need to check CityGen's code as we use it there. I thought it only took the rb and rbs files in that folder - not going deeper. I actually think that for CG we don't want it doing that either.

                Would have been nice is sub-folders where an optional argument...

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

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

                  We talk at cross-purposes 😳 - I didn't know Jim had made a require_all version...
                  I thought you meant this one that takes wildcards...tarcieri-require_all-ce01fef7205f87ade3c1e7bd626f0610f01cc013.zip the require_all.rb is in the /lib/ folder...

                  Since others might not have these perhaps the
                  Dir[path+'/rexml/parsers/'].each{|file|Sketchup::require file}
                  based version is safest ?

                  TIG

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

                    But require_all is a function bundled with SU: http://code.google.com/intl/nb/apis/sketchup/docs/loading.html

                    @unknownuser said:

                    The sketchup.rb file defines a require_all function which requires all files with the extension .rb in a given folder.

                    Another good option for automatically loading Ruby scripts is to create your own folder of Ruby scripts (outside of the Plugins directory) and add that directory to the sketchup.rb file. For example, to load all scripts in the myrubyscriptsdirectory:

                    Question is, does these third-party solutions override the native method?

                    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

                      That's a nice snippet.
                      Though, I have to see if this other version overwrites the built-in method. I think it can cause problems for CG if suddenly loads sub-folders.

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

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

                        Never knew require_all was built in... 😳
                        require_all("C:\myrubyscriptsdirectory\")
                        You then could easily use it to do subfolders thus:
                        Dir.foreach("C:\myrubyscriptsdirectory\"){|entry|require_all(entry)if FileTest.directory?(entry)}

                        TIG

                        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