How to get the path of a texture
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/04/2010 at 01:45, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10.5
Platform: Windows ;
Language(s) : C++ ;---------
Hi,how can I get the full path of a texture which is loaded into the color channel of a material?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/04/2010 at 10:45, xxxxxxxx wrote:
Hi,
I'm still having that problem. I'm pretty new to programming especially for C4D but I'm trying;)
What I`ve done so far to get the path:
BaseContainer allTexturePaths = doc->GetAllTextures(); BrowseContainer bc(&allTexturePaths); LONG id; GeData *dat; while (bc.GetNext(&id, &dat)) { temp=fn.GetFileString().GetCStringCopy(); }
that just gives me the filenames for the textures not the whole path.
I also tried with temp=fn.GetDirectory().GetString().GetCStringCopy(); which also didn't work
I also can access the filename but not the path with:
GetData().GetString(BASECHANNEL_TEXTURE)
I'm sorry if this is a stupid question but I'm really struggling here and would appreciate it if someone could help out.
Thanks:)
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/04/2010 at 12:06, xxxxxxxx wrote:
Please look at the SDK docs for the diverse methods of the Filename class, and don't miss the operator section at the end! Filename is a cross platform class that deals nicely with pretty much everything you need here.
Filename GetDocumentName(void); and Filename GetDocumentPath(void); are two methods to look into.
Also I would recommend to avoid string functions when dealing with filenames as long as you are not absolutely forced to do so. Even if you have to do so, use Cinema's String class, not C strings.
Hope it helps!
Kabe
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/04/2010 at 01:27, xxxxxxxx wrote:
Thanks for you responds:)
But I'm still no further.
I can accsess the documents path and filename with those methods but thats not exactly what I need.It would be enough if my textures always would be in a tex folder or so in my projects path. But I also need to find them if there are in a different path.
For example, my Project is in C:\Test\project.c4d
but the texture which I used in the color channel of a matieral is in C:\AllMyTextures\example.jpg .
I still don't get how to access this path. -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/04/2010 at 02:08, xxxxxxxx wrote:
You're using the wrong method of the Filename class. Don't use GetFileString(), that only returns the file without the path. Use GetString() instead - see the SDK docs.
Edit - reread your post and see you tried it, but I've just done it myself and it works fine. As Kabe said, don't use C-type strings if you can avoid it. Just use the Filename class. This code works fine, printing the full path to the console:
BaseContainer ctr = doc->GetAllTextures();
BrowseContainer bc(&ctr;);
LONG id;
GeData *dat;
while(bc.GetNext(&id;, &dat;))
{
Filename fn = dat->GetFilename();
GePrint("Texture: " + fn.GetString());
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/04/2010 at 02:43, xxxxxxxx wrote:
I think the most important bit is that Filenames are connected with the + operator, no matter if it's paths or files. Don't you ever use "", because it's not cross platform!
Kabe
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/04/2010 at 02:58, xxxxxxxx wrote:
Thanks, that helped a lot.
Its working now