Jump to content


This topic is now archived and is closed to further replies.

Guest getSet

Basic Dialog Interaction

Recommended Posts

Guest getSet
  • Topic Author
  • I want to use python to interact with c4d dialog boxes. I understand that the details of this process can vary greatly depending on exactly what is to be accomplished. But for a simple example, let's use the 'Bake Objects...' dialog. The following is a script that:

    • finds 'Cube' (note: scene must have an object named "Cube")
    • opens the timeline dope sheet
    • makes the cube the active object
    • opens the 'Bake Objects...' dialog

    What code do I add to then set 'Bake Expressions' and 'Position' check boxes to 'True' and click 'OK'?

    import c4d
    from c4d import gui
    def main():
        obj = doc.SearchObject("Cube")
        c4d.CallCommand(465001541)    # Launch 'Timeline (DopeSheet)'
        c4d.CallCommand(465001219)    # Launch 'Bake Objects...'
        # what goes here to toggle checkboxes and click 'OK'?
    if __name__=='__main__':

    I have found references to what I assume are relevant parameters in resource\modules\newman:

    • dialog definitions of IDD_BAKE in \c4d_symbols.h
    • the dialog layout in \dialogs\IDD_BAKE.res
    • and string labels in \strings_us\dialog\IDD_BAKE.str

    But I have not been able to put the pieces together. Thanks for any input.


    Updated June 7th. 2017:

    No takers on my query... Maybe my approach of interacting with the dialog box is off-base.

    It seemed like checking a few boxes and clicking OK would be no big deal. I hope to understand more in the future. 

    In my specific case I wanted "bake" the position of an object, when the position is controlled by a python tag attached to the object. In the "Bake Objects..." dialog, you would select "Bake Expressions" and "Position" and click "OK."

    For example the attached c4d scene (bakeCube.c4d) has a cube whose position is controlled by the python tag.

    I was able to "bake" the position keys for the object by browsing through the time of the document, as described at the end of this page (manual: c4d.documents.BaseDocument). Inspiration came from tcastudios, in this post (plugincafe: Press and hold button).

    With the cube selected, run this code in this script manager to "bake" the position described by the python expression tag.

    import c4d
    def BrowseDoc(doc):
      # Save current time
      ctime = doc.GetTime() 
      # Get FPS and minimum + maximum frames
      fps = doc.GetFps()
      start = doc.GetMinTime().GetFrame(fps)
      until  = doc.GetMaxTime().GetFrame(fps)
      # Look through the frames
      for frame in xrange(start, until+1):
        doc.SetTime(c4d.BaseTime(frame, fps))
        doc.RecordKey(op, c4d.ID_BASEOBJECT_REL_POSITION)
        c4d.GeSyncMessage(c4d.EVMSG_TIMECHANGED) # Update timeline
      doc.SetTime(ctime) # Set time back

    You will see the newly created position keys in the timeline dope sheet. 


    Share this post

    Link to post

    • Recently Browsing   0 members

      No registered users viewing this page.

    • Create New...


    Dear members, we are aware of few more bugs that are still present withing the theme.We just wanted to let you know that we are working to fix them as soon as possible.


    Please be aware that we are manually approving all new registrations, due to spam prevention. Please be patient in case you cannot login right away, we will approve you within 12h or less if we decide you are not potential spammer. 


    Thanks for understanding! :cowboypistol: