On 30/04/2017 at 16:01, xxxxxxxx wrote:
Hello,
coming from C++ i need your help in Python:
I need a funktion to return a object as a PointObject - for e.g. GeRayCollider.
In C++ i successfully used:
PolygonObject *Dobj;
Bool Dobj_isclone = FALSE;
if (op->GetDeformCache() || !op->IsInstanceOf(Opoint))
{
// convert Object to Polygonobject
ModelingCommandData bmd1; bmd1.op = op; bmd1.doc = op->GetDocument();
if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, bmd1)) return FALSE;
// Triangulate it
ModelingCommandData bmd2; bmd2.op = static_cast<BaseObject*>(bmd1.result->GetIndex(0));
if (!SendModelingCommand(MCOMMAND_TRIANGULATE, bmd2)) return FALSE;
Dobj = static_cast<PolygonObject*>(bmd2.op);
Dobj_isclone = TRUE;
}
else
{
Dobj = ToPoly(op);
}
This works for me in all cases, but now in Python i try:
def MakeEditable(self, op) :
if (not op) or op.CheckType(c4d.Opolygon) or op.CheckType(c4d.Ospline) :
return op
doc = c4d.documents.BaseDocument()
#doc = op.GetDocument().GetClone() for animated deformers
clone = op.GetClone()
doc.InsertObject(clone, None, None)
clone.SetMg(op.GetMg())
op = c4d.utils.SendModelingCommand(
command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
list = [clone],
mode = c4d.MODELINGCOMMANDMODE_ALL,
doc = doc
)
if op:
return op[0]
else:
return None
But this code doesn't work with deformed PointObjects (deformed BaseObjects are okay)
So, general question - is there a workaround, to "convert" EVERY object (BaseObject, PolygonObject, PointObject) including animated deformers to a (not in a hierachy) polygon- or point-object for eg. GeRayCollider or op.GetPoint() via SendModelingCommand? Is there a equivalent for "ToPoly()" - or how can a BaseObject(c4d.Opolygon) can be cast as PolygonObject to get e.g. GetPointCount()?
Or exists a alternative stable way with GetDeformCache()/GetCache()?
Thank you for any advice!
Cheers,
Mark.