Uninitialized constant
-
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 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. -
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... -
Don't think you need to prefix it with
Sketchup::
... I've only used it once, but I think I just usedrequire_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
-
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 ? -
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...
-
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 therequire_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 ? -
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?
-
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. -
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)}
Advertisement