THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/06/2003 at 17:54, xxxxxxxx wrote:
Cinema 4D Version: 7.300
Platform: Windows ;
Language(s) : C++ ;
In my shader plug-in, when the user loads a scene, I need to search for files in the scene's directory. I use the following code:
BaseDocument *mydoc = NULL;
mydoc = GetActiveDocument();
if (NULL != mydoc)
texpath = mydoc->GetPath();
Unfortunately, GetPath() returns an empty string when called during the plug-in's ReeadSettings() callback. At other times, such as at render time, GetPath() returns a valid value.
Is this a bug? Is there some other way to get the scene's path at load?
I am using the 7.3 SDK still. This problem occurs in both C4D 7 and 8.
On 02/06/2003 at 18:38, xxxxxxxx wrote:
I haven´t used GetPath() before but afaik the returned value is only empty if the file isn´t saved before. In R8 it should be GetDocumentPath(). Afaik there is no other way to get the path.
But maybe first trying to get the name with Filename current = mydoc->GetDocumentName() (this is R8, please see corresponding command for R7 that should simply be GetName() afai can remember) that will return a Filename object and you could then use current.GetDirectory() to get the directory the file is in...might be working but cannot guarantee it.
Cannot think of anything else right now...
On 03/06/2003 at 11:22, xxxxxxxx wrote:
Thanks for your post. Following your suggestion, I tried GetName(), but that returns the name without the path. However, I saw that it was returning Untitled1, so it looks like at that point, the active document is still the initial default new scene - not the scene loading. Hence, the path is empty. I checked for other documents, but that's the only one.
It seems like the only information I can get on the currently loading scene is the HyperFile that is passed into my plug-in's ReadSettings() callback. But HyperFile doesn't have any access routines to get its location.
Any other ideas out there?
On 03/06/2003 at 13:56, xxxxxxxx wrote:
hmm, right, it´s not possible to get the path with GetDirectory() then. But GetDocumentPath() works for me in R8.
But do you get the document during a hyperfile operation (just see it right now)? It might be possible that the returned Document that you get with GetActiveDocument is not valid during this operation.
Try to use hf->GetDocument(); instead.
Otherwise I don´t know of any other solution.. :
Hope that helps...
On 03/06/2003 at 13:59, xxxxxxxx wrote:
upps, sorry. It seems that this wasn´t available in the R7 SDK. It is now in R8...my fault.