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

    c4d.TEXTURETAG_MATERIAL

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 391 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 23/05/2012 at 23:57, xxxxxxxx wrote:

      Dear Cinema4D Developers,

      In ttexture.h,

      TEXTURETAG_MATERIAL = 1010, // link

      says that TEXTURETAG_MATERIAL takes a link as input. However, how can I implement this requirement using this command-line? I tried with c4d.DA_ALIASLINK but did not work.

      ID_TEXTURETAGMATERIAL=c4d.DescID(c4d.DescLevel(c4d.TEXTURETAG_MATERIAL,c4d.DA_ALIASLINK,0))

      What I want to do is to assign material " mat1 " to c4d.TEXTURETAG_MATERIAL that way. Is this possible? The entire script is shown below.

      Thank you very much for your kind of help.

      Ricardo.

      import c4d
      from c4d import gui

      def CreateKey(op, id, value, frame) :
      if not op.GetDocument() : raise Exception, "object must be in a document"

      # First check if the track type already exists, otherwise create it...
      track=op.FindCTrack(id)
      if not track:
      	track=c4d.CTrack(op,id)
      	op.InsertTrackSorted(track)
      
      curve=track.GetCurve()
      key=curve.AddKey(c4d.BaseTime(frame,doc.GetFps()))
      key["key"].SetValue(curve,value)
      

      def main() :
      fps=30
      frame=180
      doc.SetMaxTime(c4d.BaseTime(frame,fps))
      doc.SetTime(c4d.BaseTime(frame,fps))

      # Materials:
      mat1=c4d.BaseMaterial(c4d.Mmaterial)
      mat1.SetName("MM1")
      mat1[c4d.MATERIAL_COLOR_COLOR]=c4d.Vector(1,1,0)
      doc.InsertMaterial(mat1)
      
      mat2=c4d.BaseMaterial(c4d.Mmaterial)
      mat2.SetName("MM2")
      mat2[c4d.MATERIAL_COLOR_COLOR]=c4d.Vector(1,0,1)
      doc.InsertMaterial(mat2)
      
      # Textures:
      mtag=c4d.TextureTag() # Create a new texture tag...
      
      # Cubes:
      cube=c4d.BaseObject(c4d.Ocube)
      cube.SetName("MyCube")
      cube.InsertTag(mtag)
      doc.InsertObject(cube)
      
      doc.SetActiveObject(cube) # The record command needs an active object...
      cube.Message(c4d.MSG_UPDATE)
      
       **ID_TEXTURETAGMATERIAL=c4d.DescID(c4d.DescLevel(c4d.TEXTURETAG_MATERIAL,c4d.DA_ALIASLINK,0))**
      ID_TEXTURETAGOFFSETX=c4d.DescID(c4d.DescLevel(c4d.TEXTURETAG_OFFSETX,c4d.DTYPE_REAL,0))
      
      CreateKey(mtag,ID_TEXTURETAGOFFSETX,value=0.50,frame=10)
      CreateKey(mtag,ID_TEXTURETAGOFFSETX,value=0.70,frame=50)
      
       **CreateKey(mtag,ID_TEXTURETAGMATERIAL,value=mat1,frame=0)**
      
      cube.Message(c4d.MSG_UPDATE)
      
      c4d.EventAdd()
      

      if __name__=='__main__':
      main()

      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 24/05/2012 at 01:51, xxxxxxxx wrote:

        You can simply assign the material to c4d.TEXTURETAG_MATERIAL like this:

        mtag[c4d.TEXTURETAG_MATERIAL]=mat1
        

        And CKey.SetValue() only works with float values:

        key["key"].SetValue(curve,value)
        

        You should use CKey.SetGeData() instead for the bitmap. I'll ask the developers if it's possible to make this work.

        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 24/05/2012 at 09:59, xxxxxxxx wrote:

          Dear Yannick Puech,

          Thank you very much!

          So, what I have to do is to modify the definition CreateKey by this one:

          def CreateKey(op,id,value,frame) :
          if not op.GetDocument() : raise Exception, "object must be in a document"

          # First check if the track type already exists, otherwise create it...
          track=op.FindCTrack(id)
          if not track:
          	track=c4d.CTrack(op,id)
          	op.InsertTrackSorted(track)
          
          curve=track.GetCurve()
          key=curve.AddKey(c4d.BaseTime(frame,doc.GetFps()))
          
           **if type(value)==int or type(value)==float:**
          

          ** key["key"].SetValue(curve,value)**
          ** else:**
          ** key["key"].SetGeData(curve,value)**

          Isn't it?

          Thank you.

          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 25/05/2012 at 00:37, xxxxxxxx wrote:

            Yes, this should work as expected.

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