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

    Create VRay material

    Cinema 4D SDK
    python
    2
    3
    637
    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.
    • Passion3DP
      Passion3D
      last edited by Passion3D

      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?

      Thanks

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by s_bach

        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)
        doc.InsertMaterial(material)
        c4d.EventAdd()
        

        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")
        doc.InsertMaterial(material)
        
        # create standard material the other way
        material2 = c4d.Material()
        material2.SetName("second material")
        doc.InsertMaterial(material2)
        

        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
            print(mat.GetType())
        

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

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • Passion3DP
          Passion3D
          last edited by

          Hi Sebastian,

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

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