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

    Help needed with sketch material

    Cinema 4D SDK
    3
    4
    630
    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.
    • I
      InterfaceGuy
      last edited by InterfaceGuy

      I need help with the sketch material
      If I want to create and apply a regular material to, say, a cube I am fine using the code below:

      mat = c4d.BaseMaterial(c4d.Mmaterial)  # material
      tag = c4d.BaseTag(c4d.Ttexture)  # tag
      tag.SetMaterial(mat)  # assign material to tag
      obj = c4d.BaseObject(c4d.Ocube)  # create cube
      doc.InsertObject(obj)  # insert cube
      doc.InsertMaterial(mat)  # insert material
      obj.InsertTag(tag)  # apply tag to material
      

      Now if I want to do the same thing with the sketch material with the analogous code:

      c4d.Msketch = 1011014  # add missing descriptor for sketch material
      c4d.Tsketch = 1011012  # add missing descriptor for sketch tag
      
      mat = c4d.BaseMaterial(c4d.Msketch)  # material
      tag = c4d.BaseTag(c4d.Tsketch)  # tag
      tag.SetMaterial(mat)  # assign material to tag
      obj = c4d.BaseObject(c4d.Ocube) # create cube
      doc.InsertObject(obj)  # insert cube
      doc.InsertMaterial(mat)  # insert material
      obj.InsertTag(tag)  # apply tag to material
      

      I get the error message:

      AttributeError: 'c4d.BaseTag' object has no attribute 'SetMaterial'
      

      I obtained the missing descriptors from the script log, but the sketch tag and material seem to behave differently than regular materials in this regard.

      Help would be greatly appreciated!

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        1011012 is the sketch style tag which is not a subclass of the TextureTag class.
        To assign a sketch material to an object, you use the c4d.Ttexture ID as well, like in your previous example.
        If you want to do something with an actual sketch style tag, you can use the square bracket notation, like
        SketchStyle[c4d.OUTLINEMAT_LINE_DEFAULT_MAT_V]
        for the Default Visible material.

        1 Reply Last reply Reply Quote 1
        • ManuelM
          Manuel
          last edited by

          Hi,

          Nothing to add, thanks @Cairyn for the answer 🙂

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • I
            InterfaceGuy
            last edited by

            It worked!

            Thank you so much!

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