SOLVED create a material with a set texture?

I had a doubt, I wanted to place an established texture on the material created, but I don't know how, since the textures part is not a simple link type data in itself, but if I link directly where the link of the image is born is a bitmap but I don't know how it relates to the material.

import c4d

def main():
    mat = c4d.BaseList2D(c4d.Mmaterial)
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_NEW, mat)
    doc.InsertMaterial(mat)
    mat[c4d.MATERIAL_USE_REFLECTION] = False
    #mat[c4d.MATERIAL_COLOR_SHADER] ?
    #Bitmap[c4d.BITMAPSHADER_INTERPOLATION]?
    #Bitmap[c4d.BITMAPSHADER_FILENAME]?
    doc.EndUndo()
    c4d.EventAdd()

# Execute main()
if __name__=='__main__':
    main()

Hi,

The code below will show you how to do that. You must instantiate and insert a Xbitmap shader in your material. In that shader, you can define the texture path.

import c4d

def main():
    texturePath = "C:\\texture.jpg"
    
    # Creates the new material
    mat = c4d.BaseList2D(c4d.Mmaterial)
    # Start the undo stack
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_NEW, mat)
    # Insezrt the material into the document
    doc.InsertMaterial(mat)
    mat[c4d.MATERIAL_USE_REFLECTION] = False
    
    # Create a new bitmap Shader.
    bitmapShader = c4d.BaseShader(c4d.Xbitmap)
    # Define the filename for the bitmap shader
    bitmapShader[c4d.BITMAPSHADER_FILENAME] = texturePath
    
    # Set the material color paratemer.
    mat[c4d.MATERIAL_COLOR_SHADER] = bitmapShader
    
    # Insert the shader in the material's shader list
    mat.InsertShader(bitmapShader)

    # End the undo stack
    doc.EndUndo()
    
    # Pushes an update event to Cinema 4D
    c4d.EventAdd()

# Execute main()
if __name__=='__main__':
    main()

Cheers,
Manuel

Hi,

The code below will show you how to do that. You must instantiate and insert a Xbitmap shader in your material. In that shader, you can define the texture path.

import c4d

def main():
    texturePath = "C:\\texture.jpg"
    
    # Creates the new material
    mat = c4d.BaseList2D(c4d.Mmaterial)
    # Start the undo stack
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_NEW, mat)
    # Insezrt the material into the document
    doc.InsertMaterial(mat)
    mat[c4d.MATERIAL_USE_REFLECTION] = False
    
    # Create a new bitmap Shader.
    bitmapShader = c4d.BaseShader(c4d.Xbitmap)
    # Define the filename for the bitmap shader
    bitmapShader[c4d.BITMAPSHADER_FILENAME] = texturePath
    
    # Set the material color paratemer.
    mat[c4d.MATERIAL_COLOR_SHADER] = bitmapShader
    
    # Insert the shader in the material's shader list
    mat.InsertShader(bitmapShader)

    # End the undo stack
    doc.EndUndo()
    
    # Pushes an update event to Cinema 4D
    c4d.EventAdd()

# Execute main()
if __name__=='__main__':
    main()

Cheers,
Manuel

Hi.
Oh I understand, thanks for your answer, it has helped me a lot.