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

    How to get a realpath of asset in c4d R19 by python ?

    Cinema 4D SDK
    3
    4
    728
    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.
    • А
      Артём
      last edited by

      I tried "GetAllAssets()" and "GetAllTextures()", but I can't get realpath...

      this is my test code:

      # -*- coding: utf-8 -*-
      """
      该模块用于解析场景使用,
      无论插件提交,还是客户端提交,
      解析方面的工作都在这个模块实现
      """
      import c4d
      
      
      class Parse:
          # Override
          def __init__(self, doc):
              """
              parameters::
                  doc ==> 当前C4D场景
              """
              self.doc = doc
      
          def assetParse(self):
              """
              资源解析,解析场景中所有资源,
              是否存在,路径等信息
              """
              assets = c4d.documents.GetAllAssets(self.doc, False, "")
              if not assets:
                  assets = self.doc.GetAllTextures()
              
              self.assets = assets
          
          def test(self):
              self.doc.SendInfo(
                  c4d.MSG_DOCUMENTINFO_TYPE_MAKEPROJECT,
                  c4d.FORMAT_C4DEXPORT,
                  self.doc.GetDocumentName()
              )
          
      
      if __name__ == "__main__":
          c4d.CallCommand(13957) # Clear Console
          
          doc = c4d.documents.GetActiveDocument()
          doc_parsed = Parse(doc)
          doc_parsed.assetParse()
          
          # for i in doc_parsed.assets[0]:
          #     print i
              
          for i in doc_parsed.assets:
              print i
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi @Артём, first of all welcome in the plugincafe community 🙂

        You can use c4d.GenerateTexturePath to retrieve an absolute path from a relative URL.

        You should also pass the document path, you can get it with BaseDocument.GetDocumentPath.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • А
          Артём
          last edited by

          Thanks !
          It works !
          🙂

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

            Hello @Артём,

            without any further questions, we will consider this topic as solved by Monday, the 25th and flag it accordingly.

            Thank you for your understanding,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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