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

    Python Question

    Cinema 4D SDK
    2
    2
    383
    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.
    • T
      turrican
      last edited by m_adam

      Hey Guys.

      I need to load in a normal map into a standard material using Python.
      The scene is an imported FBX with over 100 materials. The color channel loads in "Texture_Colour.TGA", however the normal maps are not imported, even though they exist in the texture folder.
      What I would like is to scan the texture folder for "Texture_Normal.TGA" and apply it to the relevant material.
      Is this possible with Python?

      Cheers

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @turrican welcome in the plugincafe community.

        I moved your topic in the correct category and assigned tags, see (How to Post Questions) Please do it for your next topics.

        Regarding your question, yes it's possible to do it in python. however, I suggest you contact maxon support to report the initial bug regarding the FBX importer.

        Now you have to keep in mind here we don't code for you but help you to achieve what you want.

        So the steps in python for doing it are:

        1. Loops over each material.
        2. Retrieves their name.
        3. Create a Bitmap Shader and assign it to the correct channel of the material (normal).

        To loop over each material, keep in mind that material in Cinema 4D is BaseMaterial which is a child class of GeListNode so to loop over all material use

        # Retrieve the first material of the current document
        mat = c4d.documents.GetActiveDocument().GetFirstMaterial()
        
        # loop over each material
        while mat is not None:
            # Do the things for each mat
            mat = mat.GetNext()
        

        To create a bitmap shader (c4d.Xbitmap) and assign a texture to it find an example in shader_create_bitmap_r13.py.

        To know the ID of the normal channel, just drop and drop it into the console, see Python Console - Drag and Drop.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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