c4d.TEXTURETAG_MATERIAL



  • 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()



  • 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.



  • 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.



  • 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.


Log in to reply