Search Layer names without opening

unhandled

(Declan Halpin) #1

Hi all,

I’m pretty sure it’s not possible, so maybe this is more of a Wish. I’m hoping to search a folder for a .3dm with a particular layer name without having to open and search manually.

Anyone have a silver bullet?

dh


#2

This would be possible with a script. You could iterate through a folder, open each file (with redraw disabled), read the layer names, and if the name is present just pause the script and display the open file.

Try this:

SearchForLayer.py (1.8 KB)

Dan


#3

Here is my version just for amusement… Uses Rhino.FileIO.File3dm.Read() to read all the 3dm files in a folder and access the layer table (without actually opening the files). If it finds one or more matches to a user-input layer name, it throws up a list box with all the matches. You can actually choose one of the files in the list and have it open in a new instance of Rhino (not sure how this works on Mac Rhino), or just Esc to close.

Right now it will also find files with layers that contain the input string but might not be an exact match (i.e if you type “Default” it will find that plus Default1, My Default, etc…). I can refine it to make exact matches work if need be.

FindFileWithLayerName.py (1.5 KB)

–Mitch


(Declan Halpin) #4

Wow, thanks, Mitch! I’ll let you know how I make out.


#5

Hi Mitch,

I noticed that your script won’t open a file name that has spaces. Looks like you’ll need to get some parentheses around those file names.

Dan


#6

OK, nice catch @DanBayn, yeah should have thought of that. File3dm.Read doesn’t mind the spaces without quotes, but of course the _Run command does…

Here is the fixed script, let me know if it works OK now.

FindFileWithLayerName.py (1.8 KB)

–Mitch


#7

Yes, better now.