Getting textures via cineware
-
The goal is to extract all file paths used in the .c4d file. Is that possible via Cineware?
-
Hello @kalugin,
without a bit more precise information on what you are trying to achieve, my answer would be equally short: No, that is not (easily) possible.
Because you lack things like
GetAllAssets
,MSG_GETALLASSETS
,GeListNode::GetBranchInfo
,C4DAtom::GetDescription
,Description
, and more to either get all assets of a scene directly or iterate abstractly over a scene and all its parameters to find all parameters of a certain type.What you could do is write something that iterates over objects, tags, materials, shaders, etc. and start guessing the parameter IDs of each node you encounter. To do that you for example iterate simply from 0 to 10000 and try to retrieve a parameter with that ID with PrivateChunk::GetParameter. When the returned
GeData
holds aFilename
, you would have found a direct file parameter, when it holds aBaseContainer
, you would have to check if it (or a nested container) does contain aFilename
.The problem with all this is parameters can have up to three
DescLevel
, i.e., three IDs and not just one. So, for a scene with 1000 elements you could look at1000 elements * 10000 Level-1 * 1000 Level-2 * 1000 Level-3
, i.e. ,10.000.000.000.000
guesses and parameter retrieval attempts. And that would not even guarantee that you find everything because there can be things which exceed these ID ranges.So, long story short: This is not intended to be done with Cineware and we would strongly recommend using the Cinema 4D API instead.
You should also keep in mind that not everything that you can see in Cinema 4D might be de-serialized in the same manner by Cineware. Just because something has a "my parameter" in Cinema 4D, it does not mean that Cineware does read it.
Cheers,
Ferdinand -
Thanks for the reply. Sorry for not giving more details. I want to read a .c4d file and retrieve all texture paths without opening CINEMA4D.
-
Hey @kalugin,
yeah I mostly got that
The question is: Where do you want to retrieve the textures from: Materials and shaders at least I assume? But objects and tags can also contain links to file names, the Relief object does that for example.
But in the end, this does not change my answer that much. Doing what you want to do is not intended, and the way I proposed is (more or less [1]) the only way.
Your best options are here:
- Use the Cinema 4D C++ API.
- Or assemble a list of parameter IDs which you want to target.
a. You could even use the Cinema 4D API to do this in varying degrees of automation. - Or do what I proposed above. But you should be aware of the flaws.
Cheers,
Ferdinand[1] You could also start operating on the
Hyperfile
level or even just treat the whole file as binary data and then look for bits that look like having theFilename
memory layout. But both approaches would be out of scope of support. Dealing with the underlying Hyperfile of a chunk is a private functionality of the API and reverse engineering memory layouts and the file format is obviously out of scope of support too. -
Thanks @ferdinand. I guess I'll have to skip on that idea I was really hoping that there is something like .GetAllTextures or .GetAllAssets, but it seems I'm out of luck on this one.