On 22/08/2018 at 06:51, xxxxxxxx wrote:
I'm trying to save all of the project materials into a .c4d file?
This will be inside a CommandData plugin and unfortunately can't find a way of saving only the materials.
Does anyone have a way of dealing with this?
Thank you very much!
On 23/08/2018 at 07:16, xxxxxxxx wrote:
the goal is a C4D scene file containing only the materials of a scene, right?
The idea is to clone the needed materials into a new document, which then saved in the end.
The simplest approach could look like so (although it reverses the material order) :
doc = c4d.documents.GetActiveDocument()
newDoc = c4d.documents.BaseDocument()
mat = doc.GetFirstMaterial()
while mat is not None:
mat = mat.GetNext()
c4d.documents.SaveDocument(newDoc, 'C:/Users/Andreas/Desktop/test_all_materials.c4d', c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT)
On 23/08/2018 at 07:57, xxxxxxxx wrote:
It was wrecking my brains and is actually quite simple!
Thank you very much for that!