Save Compositing File from Python script



  • On 15/11/2015 at 14:58, xxxxxxxx wrote:

    Hi all,
    Not so much a plugin question, but a script question, hope I'm in the right place for this.

    I need to export After Effects composition files for a *lot* of c4d files and I want to automate this. So in Script Manager, I made this little script that iterates through all c4d files in a directory, loads it, sets some render parameters, and now the script needs to click the 'Save Project File...'  button and export the After Effects .aec file. But I can't find the command that actually clicks that button. It does not appear in the Script log.
     
    Is there a neat way to click this button?
    Any solutions will be rewarded with Belgian trappist ale 🙂
    Here's what I got so far:

    > import c4d
    >
    > from c4d import gui
    >
    > import os
    >
    > import sys
    >
    >
    >
    >
    > #Welcome to the world of Python
    >
    >
    >
    >
    >
    >
    >
    > def main() :
    >
    >     c4d.CallCommand(13957) # cls
    >
    >     path=c4d.storage.LoadDialog(c4d.FILESELECTTYPE_ANYTHING, "Please choose a folder", c4d.FILESELECT_DIRECTORY)
    >
    >     dirList=os.listdir(path)
    >
    >     for fname in dirList:
    >
    >         fullName = path + os.path.sep + fname
    >
    >         if fullName.endswith("*.c4d") :
    >
    >             c4d.documents.LoadFile(fullName)
    >
    >             c4d.CallCommand(12161) # Edit Render Settings...
    >
    >             renderdata()[c4d.RDATA_PROJECTFILE]=True
    >
    >             renderdata()[c4d.RDATA_PROJECTFILELOCAL]=True
    >
    >             renderdata()[c4d.RDATA_PROJECTFILEDATA]=True
    >
    >             renderdata()[c4d.RDATA_PROJECTFILETYPE]=0 #Target app: After Effects
    >
    >             # And now what?
    >
    >         
    >
    > if __name__=='__main__':
    >
    >     main()



  • On 16/11/2015 at 01:47, xxxxxxxx wrote:

    Hello and welcome,

    to click a button on can use the CallButton() function. This function needs the "object" that owns that button and the ID of that button. So to press the "Save Project File" button one needs the render settings object with that button and the button's ID. You find an example on how to use CallButton() on this button in this thread:

    Please notice that CallButton() will act like pressing the real button. This means that the file save dialog will be opened. As described in the linked thread, there is no way to avoid this.

    Best wishes,
    Sebastian



  • On 16/11/2015 at 03:00, xxxxxxxx wrote:

    Thanks Sebastian,

    So thanks to you I can now click the button and open the 'Save File' dialog. Is there a way to click the 'Save' button on this dialog using CallButton()? If so, how do I retrieve the button ID?

    I could use Sendkeys in python, but when I try to import win32com.client I get a MSVC++ Runtime error: "R6034 An application has made an attempt to load the C runtime library incorrectly."

    Thanks



  • On 16/11/2015 at 09:30, xxxxxxxx wrote:

    Hello,

    the dialog opened with"Save Project File" is a standard OS dialog and no Cinema dialog, so CallButton() cannot press any button on that dialog.

    I you use additional Python C-modules please make sure they are compatible with Cinema's Python version. In R17 the Python version was updated to 2.7 and uses Visual Studio 2012.

    best wishes,
    Sebastian


Log in to reply