Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Assigning a material to a material tag

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 278 Views
    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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 30/12/2007 at 15:54, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   10.5 
      Platform:      Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Hi,

      I want to create and assign a material in COFFEE, but this line generates an error:

      > tag- >SetMaterial(material);

      In the COFFEE doc, I found that the SetMaterial methods wants a MARKER. What is that and how can I transform a material into a marker?

      This is my code for creating & assigning a material in COFFEE:

      > _
      >      // getting the selected object
      >      if (!(obj = doc->GetActiveObject())) return;
      >      
      >      // creating a new material and a new texture tag
      >      if (!(material = AllocMaterial(Mmaterial))) { println("Error: AllocMaterial"); }
      >      if (!(tag = AllocTag(Ttexture))) { println("Error: AllocTag"); }
      >      
      >      // assigning the texture tag to the object
      >      if( !(obj->InsertTag(tag))) { println("Error: InsertTag"); }
      >      
      >      // insering the new material to the document     
      >      if (!(doc->InsertMaterial(material, NULL))) { println("Error: InsertMaterial"); }
      >      
      >      // assigning the material to the texture tag
      >      tag->SetMaterial(material);
      >      
      >      // enabling the Color channel for the material
      >      material->SetChannelState(CHANNEL_COLOR, TRUE);
      >
      >      // getting the path for the texture
      >      file = GeGetRootFilename();
      >      if (!file) return;
      >      file->RemoveLast();
      >      file->AddLast("tex.jpg");
      >      
      >      // assigning the texture to the Color channel
      >      if (!(channel = material->GetChannel(CHANNEL_COLOR))) { println("Error: GetChannel"); }
      >      if (!(container = channel->GetContainer())) { println("Error: GetContainer"); }
      >      container->SetData(CH_TEXTURE, file->GetFullString());
      >      channel->SetContainer(container);
      > _

      Thanks for your help!!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 31/12/2007 at 03:37, xxxxxxxx wrote:

        This works for me:

        > var mat = AllocMaterial(Mmaterial);
        > doc- >InsertMaterial(mat, NULL);
        >
        > mat->SetName("Hello Material");
        >
        > var tag = AllocTag(Ttexture);
        > op->InsertTag(tag);
        >
        > var bc = tag->GetContainer();
        > bc->SetData(TEXTURETAG_MATERIAL , mat);
        > tag->SetContainer(bc);

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 31/12/2007 at 05:29, xxxxxxxx wrote:

          Ah, you extract the container from the tag, modify it and write it back. OK, I'll try it out.

          Thanks

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