Grasshopper

algorithmic modeling for Rhino

Hi David,

 

Would it be possible to have an option to set the File Path Component to read to Folder Level, in addition to the current option of file level. As when exporting data the file/s are not yet created but the destination folder can be.

 

Thanks

Matt

Views: 5306

Replies to This Discussion

 

Bump!

As requested David,

Its not urgent but would be a great help.

 

Hope the move went well.

Thanks Matt

I'll have a look at that, I suppose it would then output a datatree of all the files in that folder that match some naming pattern? 

--

David Rutten

david@mcneel.com

Tirol, Austria

Hmm I had not consider the output like that.

I was thinking more that it just outputs the string of the directory location only to a folder level.

 

Currently: D:\ Folder level 1\Folder level 2\Folder level n\File Selected

New Option addtional option: D:\ Folder level 1\Folder level 2\Folder level n\Folder Selected.

Has anyone found a way to do this? I am exporting files and need to set a folder to export to. Currently I have to copy a path and paste it into panel. Not very user friendly. It would be so much better to just pick a folder.

Than we could even use Human's "directory contents" component to list the files if necessary.

Is there a way to script something that invokes the systems folder selection dialog box and can then pass the selected folder?

I just noticed that Human UI has a "file picker" component, which can be switched between "open file", "save file" and "browse folder" mode, so at least its possible.

But even though Human UI is awesome, its not a viable option for what I am using it for. I guess we just need another param component for "folder path", rather than just "file path".

Hi Tom,

thank you, but not quite. I am looking for a way to actually select a folder using the Windows dialog. Just like you can right-click on a file path component and select "set one file path". It opens the dialog and you can pick a file. What you cant do is select a folder, which is what I am after. I dont need to get the actual contents of the folder. I am writing stuff into that folder, so mostly the folder will be empty.

Ok, I almost got it using a snippet of C# I found online. Only problem I have is how to make the directory output stick. Right now it only shows when the button is pressed.

Sorry, my C# skills are like zero.

private void RunScript(bool select, ref object dir)
{

try
{
string startupPath = Application.StartupPath;
string folder = "";
if (select == true) {
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
dialog.Description = "Open a folder ";
dialog.ShowNewFolderButton = true;
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
if(dialog.ShowDialog() == DialogResult.OK)
{
folder = dialog.SelectedPath;
}
}
}

dir = folder;
}
catch (Exception)
{
MessageBox.Show("Folder selection failed!");
}

}

Can you help with that?

Attachments:

Does this work for you, Just drop it into python component and change the output

import rhinoscriptsyntax as rs
F = rs.BrowseForFolder()

Yes, that works too. But how can I trigger it with a button? Sorry, my Python skills are also quite close to 0 ;)

Here are both versions so far, both with the same problem of getting the directory output to stick.

Attachments:

We are so close to a good solution for this. Can someone with knowledge of Python or C# please have a look and make it work with a button. Right now it only works with a toggle, which is not good.

Thanks!

Hi Armin, in the attached GHPython example the Dir output will stick. That said, I'm sure there a better (i.e. Grasshoppery ways of going about this). Anywho, see if it fits your needs :)

Attachments:

Thanks, Anders.

Now its working just like I would like it to work! So much better than copy/pasting folder paths into a panel :)

Do you know if there is a rhinoscript equivalent for the file selection dialog? I always find that the right-click, set one file path, is really not very nice for someone else using the script. Its kind of hidden.

UPDATE:

Ok, I figured it out. you just use the command:

rs.OpenFileName()

instead. But weirdly when doing that you select a file, you then get the weird "no-more-clicking" bug in GH. Then you press the button again, select a new file, and then it works fine!?

Also when you press Cancel it doesnt keep the path you had before, but goes back to <Null>.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service