MGpoly
Attributes
-
ENGLISH NAME : PolygonObjectClone
-
NAME : MGpoly
-
INCLUDE : Obase
-
PATH : mograph/description/mgpoly.res
-
PLUGIN : mograph
-
MAXON online help (may not exist): MGPOLY
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.MGpoly)
doc.InsertObject(obj)
c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
#You can set parameters two different ways.
#First way
obj[c4d.MG_POLY_UPVECTOR] = c4d.MG_POLY_UPVECTOR_NONE
obj[c4d.MG_POLY_MODE_] = c4d.MG_POLY_MODE_VERTEX
obj[c4d.MG_POLY_SELECTION] = "Hello World"
obj[c4d.MG_POLY_SELECTION_ACTIVE] = True
obj[c4d.MG_POLY_LIVE_RESTRICT] = True
obj[c4d.MG_POLY_SCALEONPOLY] = True
obj[c4d.MG_POLY_SCALEONPOLY_AMOUNT] = 0.1
#Second way, using the base container.
bc = obj.GetDataInstance()
bc.SetInt32(c4d.MG_POLY_UPVECTOR,c4d.MG_POLY_UPVECTOR_NONE)
bc.SetInt32(c4d.MG_POLY_MODE_,c4d.MG_POLY_MODE_VERTEX)
bc.SetString(c4d.MG_POLY_SELECTION,"Hello World")
bc.SetBool(c4d.MG_POLY_SELECTION_ACTIVE,True)
bc.SetBool(c4d.MG_POLY_LIVE_RESTRICT,True)
bc.SetBool(c4d.MG_POLY_SCALEONPOLY,True)
bc.SetFloat(c4d.MG_POLY_SCALEONPOLY_AMOUNT,0.1)
if __name__=='__main__':
main()
C++
#include "c4d.h"
#include "../mograph/description/mgpoly.h"
void SampleFunction()
{
BaseDocument *pDoc = GetActiveDocument();
BaseObject *pObject = BaseObject::Alloc(MGpoly);
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(MG_POLY_UPVECTOR),GeData(MG_POLY_UPVECTOR_NONE),flags);
pObject->SetParameter(DescID(MG_POLY_MODE_),GeData(MG_POLY_MODE_VERTEX),flags);
pObject->SetParameter(DescID(MG_POLY_SELECTION),GeData("Hello World"),flags);
pObject->SetParameter(DescID(MG_POLY_SELECTION_ACTIVE),GeData(true),flags);
pObject->SetParameter(DescID(MG_POLY_LIVE_RESTRICT),GeData(true),flags);
pObject->SetParameter(DescID(MG_POLY_SCALEONPOLY),GeData(true),flags);
pObject->SetParameter(DescID(MG_POLY_SCALEONPOLY_AMOUNT),GeData(0.1),flags);
pObject->Message(MSG_UPDATE);
//Second way, using the base container.
BaseContainer *bc = pObject->GetDataInstance();
bc->SetInt32(MG_POLY_UPVECTOR,MG_POLY_UPVECTOR_NONE);
bc->SetInt32(MG_POLY_MODE_,MG_POLY_MODE_VERTEX);
bc->SetString(MG_POLY_SELECTION,"Hello World");
bc->SetBool(MG_POLY_SELECTION_ACTIVE,true);
bc->SetBool(MG_POLY_LIVE_RESTRICT,true);
bc->SetBool(MG_POLY_SCALEONPOLY,true);
bc->SetFloat(MG_POLY_SCALEONPOLY_AMOUNT,0.1);
pObject->Message(MSG_UPDATE);
}