Hi all,
On my Sketchup extension I use
Dir.glob(File.join(folder,"/**/*.skp"))
On my mac, its take less than 1 second to list all Sketchup files.
One of my dev use a pc and with the same library, it’s take 30 secondes to list all the file.
We try alternative to Dir.glob like Find.find, IO.popen(“find . -name ‘#{path}’”).each { |path| parse(path.chomp) } but nothing fast as Dir.glob on mac.
Do you have any advice, walk-around, tips, tricks ?
Is the folder
path a local or network path ?
Is the folder
path a local or network path ?
local in both case ( c/: for windows)
Is this any faster ?
Dir.chdir(folder) {
Dir.glob("/**/*.skp")
}
Are you running a SketchUp Windows edition under bootstrap on Mac ? ie, virtually ?
This seem to be a latency issue which can vary per hardware (disk caching, etc.) or AV scanning.
Picking a nit, but bootstrap isn’t a virtual machine, it literally boots Windows on your Mac hardware.
1 Like
DanRathbun:
Are you running a SketchUp Windows edition under bootstrap on Mac ? ie, virtually ?
This seem to be a latency issue which can vary per hardware (disk caching, etc.) or AV scanning
I try the followinf code, and still very long (same time):
Dir.chdir(folder) {
Dir.glob(“/**/*.skp”)
}
This is not [quote=“DanRathbun, post:4, topic:154665”]
under bootstrap on Mac ? ie, virtually
[/quote]
itsn’t bootrap. its a normal windows X on a normal pc
Literally c/:.Are you searching the whole C drive for sketchup files?
Noooooo . iI use it on sub folder donwload from we transfer. The same wetranfer on mac and pc
On Windows, consider not using a glob string starting with a ‘/’, as it will always search the current drive.
If there is no open model, Sketchup.active_model.path
is empty. The followings should return the model location from the preferences dialog:
Only tested on recent SU versions, and US-English…
# Windows Only - model_path is the directory listed in:
# Window - Preferences - Files - Models
require 'json'
pref_file = [
ENV['LOCALAPPDATA'].tr("\\","/"),
"SketchUp",
"SketchUp 20#{Sketchup.version[0..1]}",
"SketchUp",
"PrivatePreferences.json"
]
info = JSON.parse(File.read File.join(*pref_file), mode:'rb:UTF-8')
root = info.keys.first
model_path = info[root]["File Locations"]["Models"].tr("\\","/")
puts model_path
1 Like
Thx! @MSP_Greg . I made correction after posting
def self.glob(folder)
if Sketchup.platform == :platform_win
active_folder = File.dirname(Sketchup.active_model.path)
active_folder = Dir.pwd if active_folder == "" || active_folder == "."
tmp_file_path = File.join(active_folder,"tmp.txt")
`dir #{folder}/*.skp /b /s > #{tmp_file_path} `
tmp_file = File.open(tmp_file_path)
all_files = tmp_file.readlines.map(&:chomp)
tmp_file.close
File.delete(tmp_file_path)
return all_files&.compact
else
return Dir.glob(File.join(folder,"/**/*.skp")).sort
end
end
tt_su
March 24, 2021, 1:46pm
13
Windows’ filesystem is generally slower than Unix based systems.
1 Like
thx @tt_su for your answer. The customer was pointing on network, it was one of the reason of the extra latency (in addition to windows system)
1 Like