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. moko
    3. Topics
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 10
    • Best 2
    • Controversial 0
    • Groups 0

    Topics created by moko

    • M

      Iterate through selected Materials

      General Talk
      • • • moko
      3
      0
      Votes
      3
      Posts
      691
      Views

      M

      @ferdinand

      Thank you very much! The second way works great. I didnt get the first approach to work, but the second does well 🙂

      Here is the script if someone needs it. It is probably messy I am not a programmer, but it does write the names of the selected materials into the texturname

      import c4d from c4d import gui from c4d import storage import os #Welcome to the world of Python def changeTexture(shader): # shader ID texturePath = shader[c4d.BITMAPSHADER_FILENAME] # split aboslute path oldTexturename = os.path.split(texturePath) fileExtension = os.path.splitext(texturePath) # add prefix to newTexturename = matName + fileExtension[1] print (newTexturename) newTexturePath = os.path.join(oldTexturename[0], newTexturename) print (newTexturePath) # rename texture try : os.rename(texturePath, newTexturePath) print("Source path renamed to destination path successfully.") except OSError as error: print(error) # Assign the new value shader[c4d.BITMAPSHADER_FILENAME] = newTexturePath shader.Message(c4d.MSG_UPDATE) # Main function def main() : c4d.CallCommand(1029486) # Project Asset Inspector... c4d.CallCommand(1029816) # Select Assets of Active Elements c4d.CallCommand(1029820) # Globalize Filenames # Iterate over selected material material = doc.GetFirstMaterial() if not material: return while material: if material.GetBit(c4d.BIT_ACTIVE): shader = material.GetFirstShader() global matName matName = material.GetName() while shader: # Test if the current node is a bitmap shader. if shader.CheckType(c4d.Xbitmap) : changeTexture(shader) shader (shader.GetDown()) shader = shader.GetNext() material = material.GetNext() c4d.CallCommand(200000273) # Reload All Textures # Execute main() if __name__=='__main__': main()
    • M

      Texture renaming

      Cinema 4D SDK
      • python • • moko
      16
      0
      Votes
      16
      Posts
      2.2k
      Views

      M

      @zipit

      hm yes this sounds too complicated overall, particularly point 3 there could so much happen on the os side.
      A gui with more options like renaming the hole texturename or a replace option of certain words could be the way forward. Instead of undo it would be easy then to rename the texture with he old name etc.
      for now im happy how this works and let this solved.

      Much Thanks!
      Cheers,
      moko