Create VRay material

  • Hi all,

    I know my question doesn't directly pertain to C4D, but maybe someone here will have the answer.

    Creating a c4d material is simple, mat = c4d.Material(c4d.Mbase), but how to create a VRay material?


  • Hello,

    sorry, but this it NOT how to create a "c4d material".

    Cinema 4D has multiple, different materials. All materials are based on BaseMaterial. Thus, any material can be created using the c4d.BaseMaterial constructor and the appropriate ID:

    # create Cheen material
    material = c4d.BaseMaterial(c4d.Mcheen)

    The Cinema 4D standard material is a special case. It can be created using BaseMaterial . But there is also a dedicated class, that can be used as well: c4d.Material.

    # create standard material
    material = c4d.BaseMaterial(c4d.Mmaterial)
    material.SetName("first material")
    # create standard material the other way
    material2 = c4d.Material()
    material2.SetName("second material")

    To create a VRay material, you need the ID of that material to use it with c4d.BaseMaterial. I don't have VRay here, but you can easily obtain that ID from a already created material using GetType().

    # get the currently selected material
    mat = doc.GetActiveMaterial()
    if mat is not None:
        # print type ID

    You find more information in the C++ docs: BaseMaterial Manual

    best wishes,

  • Hi Sebastian,

    Thank you for your response. I found the identifiers of the different VRay materials in the file c4d_symbol.h.
    Everything works.

Log in to reply