Search code examples
rubysketchup

Rudy,Sketchup, list file names


This one code will list the file names in the ruby console

Dir.new('C:\\TestFolder\\').each { |file| puts file }

I would like to get it to work on the input box, for example: Getting the file list into an input box

    ents=Sketchup.active_model.active_entities

#Dir.new('C:\\TestFolder\\').each { |file| puts file }

prompts = ["Find a file?"]
defaults = [""]

list=[Dir.new('C:\\TestFolder\\').each { |file| }]

input = UI.inputbox prompts, defaults,list, "File Name"
a=input

puts a

Looking at this line:

  Dir.new('C:\\TestFolder\\').each { |file| puts file }

I believe the entire line is a loop, how do we use this loop to populate the list?


Solution

  • I found the answer, I just needed to array the list

    list = [Dir.entries("C:/TestFolder/Doit with Sketchup/")[2..-1].join('|')]