I'm creating a Sop using HDK and would like to load and save my own files containing simulation data using standard fstream. The problem is the path where the files are saved. If I output a file named foo.data it will end up in the directory from where i started houdini (if started from a shell). This is a problem when doing batch-renderings and I would instead like to know the path to the hip-file I'm currently working in (sim data would then always be written and and loaded from the same dir as the hip-file).
$HIP gives this path, but sometimes we have problems with $HIP and I'm therefore wondering if there is another way to get this path with C++ code inside a Sop, like a global with the currently open file path.
Thanks.
file path to current hip-file
2812 2 0- burnie
- Member
- 23 posts
- Joined: July 2008
- Offline
- rafal
- Staff
- 1449 posts
- Joined: July 2005
- Offline
you may want to play with the following code. I am not sure if it's just a file name or the full file path. Perhaps both, depending where the hip file is located with respect to the current working directory:
#include <OP/OP_Director.h>
#include <MOT/MOT_Director.h>
MOT_Director *mot = dynamic_cast<MOT_Director *>( OPgetDirector() );
UT_String file = mot->getFileName();
#include <OP/OP_Director.h>
#include <MOT/MOT_Director.h>
MOT_Director *mot = dynamic_cast<MOT_Director *>( OPgetDirector() );
UT_String file = mot->getFileName();
- burnie
- Member
- 23 posts
- Joined: July 2008
- Offline
-
- Quick Links