algorithmic modeling for Rhino
Hi Mark,
a grasshopper document might not have a filepath yet if it hasn't been saved. Or if it is a nested document (such as a cluster) within another document. When a document is loaded from a file, you can get the file location using the FilePath property. You can also use IsFilePathDefined to check whether or not the file path is defined. Hey ho.
Much trickier is to detect when it changes. When someone uses SaveAs, the file path will be different. There is no event associated with file path changes, so you'll need to detect this some other way. You could handle the ModifiedChanged event, but that will only work for a subset of cases.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi Mark,
for a simple implementation of FilePath as David mentions, see this example.
It would be, in short:
owner.OnPingDocument().FilePath
Thanks,
- Giulio
_______________
giulio@mcneel.com
That's great, thanks a lot.
Mark
I just added a FilePathChanged event to the GH_Document, so in future releases you can be informed whenever the FilePath property gets a new value.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Giulio,
What is the python equivalent of:
owner.OnPingDocument().FilePath
I'm trying to find the directory of grasshopper .gh file from within a python component in order to have a relative path to another .py file.
thanks
Jonathan
file_name = ghenv.Component.OnPingDocument().FilePath
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by