Here you will find documentation on all the descriptions that Cinema 4D currently has. You can list them Alphabetically, by Type or Plugin . The sample Python and C++ code is automatically generated and in some cases may not be 100% correct. If something doesn't work then please refer to the official Cinema 4D SDK documentation for more information.

IDs and information for Tpython

Tpython

Attributes

  • ENGLISH NAME : PythonTag
  • NAME : Tpython
  • INCLUDE : Texpression
  • PATH : python/description/tpython.res
  • PLUGIN : python
  • MAXON online help (may not exist): TPYTHON

Elements

ID UI Name Type Parameters Cycle
TPYTHON_FRAME FrameDependent BOOL  
TPYTHON_RESET ResetonFrame0 BOOL  
TPYTHON_CODE Code STRING
CUSTOMGUI MULTISTRING
PYTHON
SCALE_V
TPYTHON_OPENEDITOR OpenPythonEditor BUTTON  

Example Code

The following code does not use the correct values when setting the data. You should check directly in C4D for the correct values that you should use in place of the ones that are shown. This code is just to show you how to access the values for getting and setting the parameters.

Python

import c4d
from c4d import gui
def main():
    obj = c4d.BaseObject(c4d.Osphere)
    tag = obj.MakeTag(c4d.Tpython)
    doc.InsertObject(obj)
    c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
    
    #You can set parameters two different ways. 
    #First way              
    tag[c4d.TPYTHON_FRAME] = True
    tag[c4d.TPYTHON_RESET] = True
    tag[c4d.TPYTHON_CODE] = "Hello World"
    
    #Second way, using the base container.
    bc = tag.GetDataInstance()
    bc.SetBool(c4d.TPYTHON_FRAME,True)
    bc.SetBool(c4d.TPYTHON_RESET,True)
    bc.SetString(c4d.TPYTHON_CODE,"Hello World")

if __name__=='__main__':
    main()
             

C++

#include "c4d.h"
#include "../python/description/tpython.h"
void SampleFunction()
{
    BaseDocument *pDoc = GetActiveDocument();
    BaseObject *pObject = BaseObject::Alloc(Osphere);
    pDoc->InsertObject(pObject);
    pDoc->StartUndo();
    pDoc->AddUndo(UNDOTYPE_NEW,pObject);
    pDoc->EndUndo();
    pDoc->StartUndo();
    BaseTag *pTag = pObject->MakeTag(Tpython);
    pDoc->AddUndo(UNDOTYPE_NEW,pTag);
    pDoc->EndUndo();
    pObject->Message(MSG_UPDATE);
    
    //You can set parameters two different ways. 

    //First way              
    //Some objects do not store all their data in the container. You need to use GetParameter()/SetParameter() instead. 

    DESCFLAGS_SET flags = DESCFLAGS_SET_PARAM_SET;
    pTag->SetParameter(DescID(TPYTHON_FRAME),GeData(true),flags);
    pTag->SetParameter(DescID(TPYTHON_RESET),GeData(true),flags);
    pTag->SetParameter(DescID(TPYTHON_CODE),GeData("Hello World"),flags);
    pTag->Message(MSG_UPDATE);            

    //Second way, using the base container.
    BaseContainer *bc =     pTag->GetDataInstance();
    bc->SetBool(TPYTHON_FRAME,true);
    bc->SetBool(TPYTHON_RESET,true);
    bc->SetString(TPYTHON_CODE,"Hello World");
    pTag->Message(MSG_UPDATE);                                                      
}
             

Buttons

This node has buttons. Buttons can manually be executed by calling the following code

Python

c4d.CallButton(tag,c4d.TPYTHON_OPENEDITOR)

C++

DescriptionCommand dc;
dc.id = DescID(TPYTHON_OPENEDITOR);             
pTag->Message(MSG_DESCRIPTION_COMMAND, &dc);