Bend deformers



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

    On 23/05/2012 at 10:17, xxxxxxxx wrote:

    Dear Cinema4D Developers,

    I am having a hard time trying to run the script shown below. The problem is that these two commands are not working at all and I do not know what I am doing wrong:

    CreateKey(bend,ID_DEFORMOBJECTSTRENGTH,value=0.7854,frame=0)
    CreateKey(bend,ID_DEFORMOBJECTSIZE_X,value=400,frame=0)

    Could you help me please?

    Thank you very much!

    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=90
    doc.SetMaxTime(c4d.BaseTime(frame,fps))
    doc.SetTime(c4d.BaseTime(frame,fps))

    # Materials:
    mat=c4d.BaseMaterial(c4d.Mmaterial)
    doc.InsertMaterial(mat)
    
    # Textures:
    mtag=c4d.TextureTag() # Create a new texture tag...
    mtag.SetMaterial(mat) # Link it to our new material...
    
    # Cubes:
    cube=c4d.BaseObject(c4d.Ocube)
    cube.SetName("MyCube")
    cube.InsertTag(mtag)
    doc.InsertObject(cube)
    
    # Deformers:
    bend=c4d.BaseObject(c4d.Obend)
    bend.SetName("MyBend")
    doc.InsertObject(bend,cube) # Add it to the Object Manager as a child of the cube...
    
    # ID DEFINITIONS
    ID_PRIMCUBESUBX=c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_SUBX,c4d.DTYPE_LONG,c4d.Ocube))
    ID_PRIMCUBESUBY=c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_SUBY,c4d.DTYPE_LONG,c4d.Ocube))
    ID_PRIMCUBESUBZ=c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_SUBZ,c4d.DTYPE_LONG,c4d.Ocube))
    
    ID_PRIMCUBELEN_X=c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_LEN,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_X,c4d.DTYPE_REAL,0))
    ID_PRIMCUBELEN_Y=c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_LEN,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_Y,c4d.DTYPE_REAL,0))
    ID_PRIMCUBELEN_Z=c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_LEN,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_Z,c4d.DTYPE_REAL,0))
    
    ID_IDBASEOBJECTRELPOSITION_X=c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_X,c4d.DTYPE_REAL,0))
    ID_IDBASEOBJECTRELPOSITION_Y=c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_Y,c4d.DTYPE_REAL,0))
    ID_IDBASEOBJECTRELPOSITION_Z=c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_Z,c4d.DTYPE_REAL,0))
    
    ID_DEFORMOBJECTSTRENGTH=c4d.DescID(c4d.DescLevel(c4d.DEFORMOBJECT_STRENGTH,c4d.DTYPE_REAL,c4d.Obend))
    ID_DEFORMOBJECTSIZE_X=c4d.DescID(c4d.DescLevel(c4d.DEFORMOBJECT_SIZE,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_X,c4d.DTYPE_REAL,0))
    ID_DEFORMOBJECTSIZE_Y=c4d.DescID(c4d.DescLevel(c4d.DEFORMOBJECT_SIZE,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_Y,c4d.DTYPE_REAL,0))
    ID_DEFORMOBJECTSIZE_Z=c4d.DescID(c4d.DescLevel(c4d.DEFORMOBJECT_SIZE,c4d.DTYPE_VECTOR,0),c4d.DescLevel(c4d.VECTOR_Z,c4d.DTYPE_REAL,0))
    
    
    
    doc.SetActiveObject(cube) # the record command needs an active object
    cube.Message(c4d.MSG_UPDATE)
    
    CreateKey(cube,ID_PRIMCUBESUBZ,value=1,frame=0)
    CreateKey(cube,ID_PRIMCUBESUBZ,value=15,frame=10)
    
    CreateKey(cube,ID_PRIMCUBELEN_X,value=100,frame=0)
    CreateKey(cube,ID_PRIMCUBELEN_X,value=500,frame=40)
    
    CreateKey(cube,ID_IDBASEOBJECTRELPOSITION_X,value=105.0,frame=0)
    CreateKey(cube,ID_IDBASEOBJECTRELPOSITION_X,value=50.0,frame=10)
    
    
    doc.SetActiveObject(bend) # the record command needs an active object
    bend.Message(c4d.MSG_UPDATE)
    
    CreateKey(bend,ID_IDBASEOBJECTRELPOSITION_X,value=200,frame=0)
    CreateKey(bend,ID_IDBASEOBJECTRELPOSITION_X,value=700,frame=20)
    
     **CreateKey(bend,ID_DEFORMOBJECTSTRENGTH,value=0.7854,frame=0)**
    

    ** CreateKey(bend,ID_DEFORMOBJECTSIZE_X,value=400,frame=0)**

    c4d.EventAdd()
    

    if __name__=='__main__':
    main()



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

    On 23/05/2012 at 11:17, xxxxxxxx wrote:

    Hello adarpodracir ,

    Welcome to the plugincafe!

    You over-complicate it a little. :) For single-valued Parameters, you can give the ID directly as an
    argument to FindCTrack(). For e.g. vector-fields, you have to specify a DescID.

    track = op.FindCTrack(c4d.LIGHT_BRIGHTNESS)
    
    descid = c4d.DescID(c4d.DescLevel(c4d.PRIM_CUBE_LEN), c4d.DescLevel(c4d.VECTOR_X))  
    track = op.FindCTrack(descid)
    

    That's basically it. I actually don't know what the t_creator argument should be in the constructor
    of c4d.DescLevel, but it is enclosed in brackets, which means it is optional. And it seems to be the
    cause of the error you get.

    Removing c4d.Obend as argument for t_creator seems to fix the script.

    ID_DEFORMOBJECTSTRENGTH=c4d.DescID(c4d.DescLevel(c4d.DEFORMOBJECT_STRENGTH,c4d.DTYPE_REAL)) # ,c4d.Obend))
    

    Best,
    -Nik



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

    On 23/05/2012 at 23:25, xxxxxxxx wrote:

    Thank you very much. Works!


Log in to reply