pop-up dialog windows and c4dpy : the problem



  • hello, i try to open any type of cinema 4d dialog window with my script via c4dpy (open file, save file dialogs etc) and get nothing. it seems like c4dpy ignores any type of pop-up windows. how can i use usual dialog windows or pop-up dialogs with c4dpy? is there any way to do this?

    thanks!



  • Hi,

    I always wondered about that too, but from what I understand (this isn't documented anywhere), all Cinema GUI-functionality is off limits in c4dpy. You would have to use one of the gui-frameworks to open a dialog. You could either use Python's native tkinter (Cinema's Python does not include it) or something like qt. In tkinter opening file dialogs is quite straight forward (this is Python 3 code).

    import tkinter
    from tkinter import filedialog
    
    file_names = filedialog.askopenfiles()
    file_object = filedialog.asksaveasfile()
    
    print (file_names)
    print (file_object)
    

    Cheers,
    zipit



  • Hi @wob unfortunately this is not possible, c4dpy is a regular Cinema 4D executed as command line with the NoGui, and as all NoGui Cinema 4D execution, GeDialog is disabled.

    So its a limitation, and as said by zipit there is no Tkinter shipped with Cinema 4D in order to force people to use Cinema 4D dialog.

    So possible workarounds are:

    • Install pip and install any 3rd party GUI module (but this is not officially supported by Cinema 4D so you may have some odd issues, but it should work).
    • Execute a python script before from a system python installation that will create the Dialog and later execute c4dpy to do the Cinema 4D work.

    Cheers,
    Maxime.


Log in to reply