Oetarget
Attributes
-
ENGLISH NAME : Target
-
NAME : Oetarget
-
INCLUDE : Obase
-
INCLUDE : Oedeformer_panel
-
PATH : mograph/description/oetarget.res
-
PLUGIN : mograph
-
MAXON online help (may not exist): OETARGET
Elements
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.Oetarget)
doc.InsertObject(obj)
c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
#You can set parameters two different ways.
#First way
obj[c4d.MGTARGETEFFECTOR_STRENGTH] = 0.1
obj[c4d.MGTARGETEFFECTOR_SELECTION] = "Hello World"
obj[c4d.MGTARGETEFFECTOR_MODE] = c4d.MGTARGETEFFECTOR_MODE_OBJECT
obj[c4d.MGTARGETEFFECTOR_SETWEIGHT] = True
obj[c4d.MGTARGETEFFECTOR_PITCH] = True
obj[c4d.MGTARGETEFFECTOR_REVERSEVECTOR] = True
obj[c4d.MGTARGETEFFECTOR_PRIMITIVEAXIS] = c4d.MGTARGETEFFECTOR_PRIMITIVEAXIS_NONE
obj[c4d.MGTARGETEFFECTOR_REACT] = True
obj[c4d.MGTARGETEFFECTOR_RANGE] = 0.1
obj[c4d.ETARG_RANGE_STRENGTH] = 0.1
#Second way, using the base container.
bc = obj.GetDataInstance()
bc.SetFloat(c4d.MGTARGETEFFECTOR_STRENGTH,0.1)
bc.SetString(c4d.MGTARGETEFFECTOR_SELECTION,"Hello World")
bc.SetInt32(c4d.MGTARGETEFFECTOR_MODE,c4d.MGTARGETEFFECTOR_MODE_OBJECT)
bc.SetBool(c4d.MGTARGETEFFECTOR_SETWEIGHT,True)
bc.SetBool(c4d.MGTARGETEFFECTOR_PITCH,True)
bc.SetBool(c4d.MGTARGETEFFECTOR_REVERSEVECTOR,True)
bc.SetInt32(c4d.MGTARGETEFFECTOR_PRIMITIVEAXIS,c4d.MGTARGETEFFECTOR_PRIMITIVEAXIS_NONE)
bc.SetBool(c4d.MGTARGETEFFECTOR_REACT,True)
bc.SetFloat(c4d.MGTARGETEFFECTOR_RANGE,0.1)
bc.SetFloat(c4d.ETARG_RANGE_STRENGTH,0.1)
if __name__=='__main__':
main()
C++
#include "c4d.h"
#include "../mograph/description/oetarget.h"
void SampleFunction()
{
BaseDocument *pDoc = GetActiveDocument();
BaseObject *pObject = BaseObject::Alloc(Oetarget);
pDoc->InsertObject(pObject);
pDoc->StartUndo();
pDoc->AddUndo(UNDO_NEW,pObject);
pDoc->EndUndo();
EventAdd(EVENT_FORCEREDRAW);
//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;
pObject->SetParameter(DescID(MGTARGETEFFECTOR_STRENGTH),GeData(0.1),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_SELECTION),GeData("Hello World"),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_MODE),GeData(MGTARGETEFFECTOR_MODE_OBJECT),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_SETWEIGHT),GeData(true),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_PITCH),GeData(true),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_REVERSEVECTOR),GeData(true),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_PRIMITIVEAXIS),GeData(MGTARGETEFFECTOR_PRIMITIVEAXIS_NONE),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_REACT),GeData(true),flags);
pObject->SetParameter(DescID(MGTARGETEFFECTOR_RANGE),GeData(0.1),flags);
pObject->SetParameter(DescID(ETARG_RANGE_STRENGTH),GeData(0.1),flags);
pObject->Message(MSG_UPDATE);
//Second way, using the base container.
BaseContainer *bc = pObject->GetDataInstance();
bc->SetFloat(MGTARGETEFFECTOR_STRENGTH,0.1);
bc->SetString(MGTARGETEFFECTOR_SELECTION,"Hello World");
bc->SetInt32(MGTARGETEFFECTOR_MODE,MGTARGETEFFECTOR_MODE_OBJECT);
bc->SetBool(MGTARGETEFFECTOR_SETWEIGHT,true);
bc->SetBool(MGTARGETEFFECTOR_PITCH,true);
bc->SetBool(MGTARGETEFFECTOR_REVERSEVECTOR,true);
bc->SetInt32(MGTARGETEFFECTOR_PRIMITIVEAXIS,MGTARGETEFFECTOR_PRIMITIVEAXIS_NONE);
bc->SetBool(MGTARGETEFFECTOR_REACT,true);
bc->SetFloat(MGTARGETEFFECTOR_RANGE,0.1);
bc->SetFloat(ETARG_RANGE_STRENGTH,0.1);
pObject->Message(MSG_UPDATE);
}