SOLVED Python Question

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?


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

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