Navigation

    • Register
    • Login
        No matches found
    • Search
    1. Home
    2. Tomoya
    T

    Tomoya

    @Tomoya

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

    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    Tomoya Follow

    Best posts made by Tomoya

    This user hasn't posted anything yet.

    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 •