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
    1. Maxon Developers Forum
    2. Tomoya
    T
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    Tomoya

    @Tomoya

    0
    Reputation
    2
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Tomoya Unfollow Follow

    Latest posts made by Tomoya

    • Assign materials to Objects using Python Un-subscribe from this thread

      Hello!
      I would like to automate the replacement of materials loaded in Alembic.

      How can I change the attached python code to replace the material with a material with the same name as the one applied in Alembic?

      I would appreciate your advice.

      I am new to the forum, so please forgive my unfamiliarity.

      import re
      import c4d
      
      def main():
        doc = c4d.documents.GetActiveDocument()
        oplist = doc.GetObjects()
        if not oplist: return
        matlist = doc.GetMaterials()
        if not matlist: return
        if oplist:
            for op in oplist:
              opname = op.GetName()       
              mat = doc.SearchMaterial(opname)
              if not mat:
                for mat in matlist:
                    mname = mat.GetName()
              mname = mat.GetName()
              match = re.match(opname, mname)
              if match:
                textag = c4d.TextureTag()
                textag.SetMaterial(mat)
                textag[c4d.TEXTURETAG_PROJECTION]=c4d.TEXTURETAG_PROJECTION_UVW
                op.InsertTag(textag)
        c4d.EventAdd()
      if __name__==‘__main__’:
        main()
      
      posted in Cinema 4D SDK python r25
      T
      Tomoya