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

    Copy Assets to new Location

    Cinema 4D SDK
    python
    2
    3
    511
    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.
    • C
      cgweasel
      last edited by

      I would like a script to collect all my assets in a folder. Just like the option "save project with assets". But i do not want to save the project and start copying files around. I just want to collect the textures.

      I tried c4d.documents.SaveProject() and c4d.documents.GetAllAssetsNew() but I can´t get it to work. I am pretty sure this is quite a short script. Could someone help me out?

      Oh, and would someone explain to me this error:
      TypeError: unable to convert builtins.list to @net.maxon.interface.url-C

      Thanks.

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @cgweasel
        last edited by ferdinand

        Hello @cgweasel,

        welcome to the forum and thank you for reaching out to us. I would recommend having a look at our Forum Guidelines as they line out important aspects of the support provided by us here.

        What is missing here for my understanding is context, the version you are using, and executable code. Let's start with the simple one.

        TypeError: unable to convert builtins.list to @net.maxon.interface.url-C

        This means that you are passing something a list (possibly a list of maxon.Url) that expects an argument of type maxon.Url. Or that you did something else incorrectly which causes this error to bubble up somewhere in our wrapper code. Without your code it is not possible to help you more concretely.

        I would like a script to collect all my assets in a folder.

        Which brings us to the major ambiguity: What do you mean by 'assets' here? There are two asset concepts in the Cinema 4D API. Assests in the classic API sense, as reflected in 'Save Project with Assets', and Maxon Asset API assets, as reflected by the Asset Browser.

        There is the idea of the classic API and maxon API in our APIs. Save Project with Assets, c4d.documents.SaveProject(), c4d.documents.GetAllAssetsNew() and the project assets related messages are all classic API concepts. The Asset API, the backend of the Asset Browser, and maxon.Url are both maxon API concepts.

        c4d.documents.GetAllAssetsNew() will yield all assets that are used by a scene as a list of dictionaries. You could iterate over them and copy these files to any location you would like to, as long as you have read and write access to the source and destination location. Showing how to copy files with Python is out of scope of support, I cannot do this for you especially when you have provided no code to start with. SaveProject() will save a document with all its assets just as the entry in the file menu. But just as for the file menu command, this will not necessarily reflect Asset Browser assets, when they have not been imported as Xrefs, as they are then just things in your scene, and not assets anymore.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • C
          cgweasel
          last edited by

          Hi ferdinand,

          I am very sorry for my lack of reading the Guidelines properly.

          But still, very huge thanks to you for the explanation anyway. This already helped me. I will try things out and will probably come back here with some code. 😄

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