Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    API questions

    Cinema 4D SDK
    2
    3
    584
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jesse
      last edited by m_adam

      is there a built in way to convert the render setting file tokens to what they are represent?
      also is there a way to save a .c4d file with out the file location window popping up using python?

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @jesse first of all welcome in the plugincafe community.

        I would like to point you to a few rules for your next topics (I've set up this one correctly).

        • How to Post Questions, especially the tagging part and the correct category.
        • Q&A New Functionality.

        Now in regards to the first question, yes it's possible you should use c4d.modules.tokensystem.StringConvertTokensFilter or c4d.modules.tokensystem.FilenameConvertTokensFilter.

        A quick example:

        import c4d
        
        
        def main():
            # Defines a path, with the $frame and $prj token
            path = r"/myprojects/topnotchproject/theimage_$frame_$prj.png"
            print(path)
        
            # Setups the RenderPathData
            rpd = {'_doc': doc, '_rData': doc.GetActiveRenderData(), '_rBc': doc.GetActiveRenderData().GetData(), '_frame': 1}
        
            # Excludes the project token to the "tokenization"
            exclude = ['prj']
        
            # Renders token to string
            finalFilename = c4d.modules.tokensystem.StringConvertTokensFilter(path, rpd, exclude)
            print(finalFilename)
        
            # Renders tokens to string and also change / to \
            finalFilename = c4d.modules.tokensystem.FilenameConvertTokensFilter(path, rpd, exclude)
            print(finalFilename)
        
        
        if __name__ == '__main__':
            main()
        

        While it's in C++, it's still worth looking at the Token Manual.

        Then for the second question, you can save a .c4d file (or a document) by calling c4d.documents.SaveDocument, by default dialog are not allowed to pop up.

        If you have any questions, let me know.
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        J 1 Reply Last reply Reply Quote 2
        • J
          jesse @m_adam
          last edited by

          @m_adam thanks
          so using c4d.documents.SaveDocument the window is still showing up.. even with "SAVEDOCUMENTFLAGS_NONE" or "SAVEDOCUMENTFLAGS_AUTOSAVE"
          could it still be showing up because of an error in the file path its trying to save to or something like that?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post