Import Model Block Definition: Relative File Path

Is it possible to specify a path that is relative to the location of the Grasshopper definition?

(I guess one could generate the path using Python, but I hope there is a simpler solution.)

Hi @feklee

With metahopper it is possible.

https://www.food4rhino.com/en/app/metahopper

Thanks, but I try to avoid plugins for small stuff like this. I should dig up the Python code from when I needed the path of the definition the last time. Support for relative paths throughout Grasshopper and Rhino is my biggest wish for version 9. It would make life so much easier!

I think Grasshoper’s File Path component should have the path of the current definition as an option.

import Grasshopper

filepath = Grasshopper.Instances.DocumentServer[0].FilePath
print(filepath)

this is the python sollution

Thank you! I modified it to get me the path of my assets:

import Grasshopper, os
filepath = Grasshopper.Instances.DocumentServer[0].FilePath
print(os.path.dirname(filepath) + "\\assets\\")

Using the Query Directory component you can connect an empty panel to the D input and it will output the files in the directory where the Grasshopper file is saved

I just played with it, for the first time. This is a great component, which explicitly resolves paths relative to the current document.

Thank you!