Save Project - Missing Assets

On 27/01/2018 at 09:27, xxxxxxxx wrote:

Hi guys!

I'm trying to recreate the "Save Project with Assets" function from menu and I have some doubts about it, here is my actual code:

import c4d
def get_targetPath() :
    targetPath =
    if targetPath[-4:] == ".c4d":
        targetPath = targetPath[:-4]
    return targetPath     
def saveProject() :
    docpath=doc.GetDocumentPath() #this would be the last path of the get assets function?
    targetPath = get_targetPath()
    assets=c4d.documents.GetAllAssets(doc, True, docpath) #list of assets to copy
    missingAssets = None #list of missing assets
    c4d.documents.SaveProject(doc, flags, targetPath, assets, missingAssets) #do collect, what i need to put in missing assets?
if __name__=='__main__':

-What I need to assign to lastPath before to execute the function "c4d.documents.GetAllAssets(doc, allowDialogs, lastPath)"? 
-How can I get the missingAssets list for the "c4d.documents.SaveProject(doc, flags, targetPath, assets, missingAssets)" function? Because if I have missing assets from the "GetAllAssets" the function return None and not the missing assets.


On 29/01/2018 at 06:06, xxxxxxxx wrote:


actually the "assets" and "missingAssets" parameters of SaveProject() as well as the "lastPath" parameter of GetAllAssets() are output parameters.

Additionally to the list of assets in parameter "assets" SaveProject() sets missingAssets (e.g. textures not found under the specified path), but only if flag SAVEPROJECT_DIALOGSALLOWED is not set.

GetAllAssets() will set lastPath to the path chosen by a user, if an asset was missing.

So, you don't need to call GetAllAssets() before SaveProject(), it is used internally anyway.

But you need to provide empty lists for these parameters.
Roughly like so:

    missingAssets = []
    assets = []
    targetPath = "some path"
    res = c4d.documents.SaveProject(doc, c4d.SAVEPROJECT_ASSETS | c4d.SAVEPROJECT_SCENEFILE, targetPath, assets, missingAssets)

We will try to improve (and fix) both C++ and Python API documentation on this topic.

On 04/02/2018 at 08:42, xxxxxxxx wrote:

Hi Andreas!

Great, now I understand how work this parameters. And if I set the flag SAVEPROJECT_DIALOGSALLOWED, is there a method to get the missing assets? Because if I set this flag the missing assets appears in the assets list.


On 05/02/2018 at 04:30, xxxxxxxx wrote:

I'm afraid, you can't. The logic is probably "if the user decided an asset path is pointing nowhere, then it's no longer missing, but rather deliberately set defunct.

On 05/02/2018 at 06:42, xxxxxxxx wrote:

Alright, thanks a lot for your help.