Last active
March 28, 2016 17:04
-
-
Save StepMaher/d85b59a7c38108dec3c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Finds a file in the same directory as the Grasshopper file. | |
Inputs: Name: File name and extiestion to grab. | |
Outputs: Path: Full file path. | |
""" | |
# Name component | |
ghenv.Component.Name = "Relative File Path" | |
ghenv.Component.NickName = "RelFilePath" | |
# Import libraries | |
import os | |
import Grasshopper as gh | |
# Get GH file path | |
gh_path = ghdoc.Path | |
dir = os.path.dirname(os.path.realpath(gh_path)) | |
# Join GH file path and file name | |
path = os.path.join(dir, Name) | |
# Test if that file exists | |
if os.path.isfile(path) == True: | |
Path = path # Declare output param | |
else: | |
msg = "File does not exist." | |
ghenv.Component.AddRuntimeMessage(gh.Kernel.GH_RuntimeMessageLevel.Warning, msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment