Hi,
That's right, the error you're getting is related to the type of the passed object to be processed by the PolygonReduction
.
The sample code shouldn't try to process an object that isn't a PolygonObject
because there's this check at the beginning:
if not polyObject.IsInstanceOf(c4d.Opolygon):
return
To convert a BaseObject
to a PolygonObject
the Current State to Object modeling command can be used.
The utility function below invokes the MCOMMAND_CURRENTSTATETOOBJECT
:
def CSTO(obj, doc, inheritance, keepAnimation, noGenerate):
bc = c4d.BaseContainer()
bc.SetBool(c4d.MDATA_CURRENTSTATETOOBJECT_INHERITANCE, inheritance)
bc.SetBool(c4d.MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, keepAnimation)
bc.SetBool(c4d.MDATA_CURRENTSTATETOOBJECT_NOGENERATE, noGenerate)
res = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT, list=[obj.GetClone()], bc=bc, doc=doc)
if isinstance(res, list):
return res[0]
else:
return None
The CSTO() function can then be invoked like this:
if not polyObject.IsInstanceOf(c4d.Opolygon):
polyObject = CSTO(polyObject, doc, True, True, False)
if polyObject is None:
return
I moved the topic to "CINEMA 4D DEVELOPMENT" category and I turned it into a question and answer (you can do this by yourself, see Q&A New Functionality).