Grasshopper

algorithmic modeling for Rhino

So I have been messing around with the command line commands of Grasshopper and using Python scripts to do various things.

One thing I have noticed is that the "-grasshopper Document Open" command as well as the Python method is a bit fussy when it comes to file paths.

It doesn't accept file paths that have spaces in them, unless it is surrounded by " ", which is not a problem when using the Python command gh.OpenDocument(String). But then it doesn't work at all with network paths.

-grasshopper Document Open C:\filepath with spaces    -> not working

-grasshopper Document Open "C:\filepath with spaces"    -> working

-grasshopper Document Open "X:\mapped network drive filepath"    -> not working

-grasshopper Document Open "\\servername\share\filepath with spaces"    -> not working

This is true for the command line command as well as the Python methods.

Using the normal open dialog of GH, you can use any format for the filepath and it works.

What could be the reason? How should I pass file paths to it, especially ones on network shares?

Views: 842

Replies to This Discussion

Rhino treats spaces as ENTER presses in the command line. If you're entering a string which *may* contain whitespace, you always need to encase it in double-quotes.

I'm not surprised the files from the server aren't found, Grasshopper asks the OS whether or not the file specified by the user exists, and the OS goes "hey, that's not a file path, it's some weird online stuff, therefore 'no' that file does not exist."

I do not know how mapped drives are supposed to work within the .NET System.IO namespace. Frankly I've never looked into that much so it could well be I'm doing something wrong or not doing enough to detect alternative file path notation.

Ok, that kind of makes sense. The OS is pretty good at understanding network paths though.

In fact I have GHLauncher installed and if I use a network path with the format \\server\share\path to file with spaces using the -open command in Rhino it works! Doing the same from a Python script also works, but I have to escape a lot of characters in the path. Adding to that for some stupid reason file paths in windows actually use the escaping character \ as their seperator. So now the string I have to pass looks something like this:

"\"\\\\JHH-SERVER\jhh server\\5_BIBLIOTHEK\\10_Skripte\SC_Curve_Composer_V1.3b.gh\""

If you have a number at the beginning of a folder name, then you need to escape the \ before it too, but not if it starts with a letter.

Either way, the gh.OpenDocument still doesn't handle anything with spaces or networks paths it would seem. Maybe you can have a look at the way it handles network paths, because they DO work in the Rhino command line. Every architectural company I have seen uses some kind of file server, so network paths are something that should work in GH too, especially in light of GH for Mac and the fact that UNC paths work on both Windows and Mac.

So for now, I think I will give up on using Python to open files in GH - what I wanted to achieve is being able to open several instances of Rhino+GH automatically to enable parallel computing of the same sketch with different variables. Doing it manually works well, but I thought it would be nice to automate it.

The only other "solution" I can think of is to use local paths and then have something like  bittorrent sync upload the changes to the server, but its adding complexity to something thats not necessary. All the GH files I work on are on our server and it works just fine.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service