Read File relative to Hops file location?

I’m loading a script using the hops component.

The script tries loading external files which are stored on a relative path.

To be able to read file with the Read File component, I convert the relative path in an absolute path.

But it seems like the Hops script is run from another location then where it is stored on the drive, resulting in a wrong path:

Got:
Could not create a file event watcher for: C:\Program Files\Rhino 7\Plug-ins\IronPython\Lib\aec_brisesoleil\aec_brisesoleil.py: component "Read File"

Expected:
C:\Hops\pattern_library\aec_brisesoleil\aec_brisesoleil.py

Is there a way to read files relative to the Hops file?

Hi @AndyPayne, I’m trying to read a file that is in the same folder as the Hops definition, but without luck. It seems like Hops is still looking in the wrong folder.

Could not find file 'C:\Users\shwde\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\Hops\0.15.0\compute.geometry\test.html'.: component "Read File" (3ddee979-2be6-47d5-9175-6b8d53859e38)

Is this supposed to work?

So… if I use this file (see below)
image

and then I reference that file into a Hops component like this
image

Then it appears to work on my end. You have to set the path as a full path. Relative paths don’t work (to my knowledge). Also, what component are you using on the top “RelPath”?

Thank you Andy!

The point is that I want to be able to access a file that is stored relatively to the Hobs file,
but apperently the Hops file is run from

\Roaming\McNeel\Rhinoceros\packages\7.0\Hops\0.15.0\compute.geometry\

instead of its stored location.

Any attempt to access a file by converting a relative path into an absolute path will hence fail.

The component is from Metahopper:

Correct. At this moment, absolute paths are the only paths that are allowed. It is on our to do list as a feature to add (ie. relative paths)… but that isn’t currently available just yet. Sorry about that. I’ll will report back here whenever that feature is added. Thanks for the feedback.

Thanks for your clear answer; looking forward to the feature!

Any development on this now a year later?