Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Save All Materials

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 1.4k Views
    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.
    • H Offline
      Helper
      last edited by

      On 22/08/2018 at 06:51, xxxxxxxx wrote:

      Hi everyone,

      I'm trying to save all of the project materials into a .c4d file?
      This will be inside a CommandData plugin and unfortunately can't find a way of saving only the materials.

      Does anyone have a way of dealing with this?

      Thank you very much! 🙂

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 23/08/2018 at 07:16, xxxxxxxx wrote:

        Hi,

        the goal is a C4D scene file containing only the materials of a scene, right?

        The idea is to clone the needed materials into a new document, which then saved in the end.

        The simplest approach could look like so (although it reverses the material order) :

            doc = c4d.documents.GetActiveDocument()
            newDoc = c4d.documents.BaseDocument()
            mat = doc.GetFirstMaterial()
            while mat is not None:
                newDoc.InsertMaterial(mat.GetClone(c4d.COPYFLAGS_0))
                mat = mat.GetNext()
            c4d.documents.SaveDocument(newDoc, 'C:/Users/Andreas/Desktop/test_all_materials.c4d', c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT)
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 23/08/2018 at 07:57, xxxxxxxx wrote:

          Hi Andreas,

          It was wrecking my brains and is actually quite simple! 🙂

          Thank you very much for that!

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