THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/03/2010 at 06:54, xxxxxxxx wrote:
I still don't see why you need a second document for that. It definitely works even when the source object is not selected:
MyMenuPlugin::Execute(doc)
{
var bc = new(BaseContainer);
bc->SetData(MDATA_CURRENTSTATETOOBJECT_INHERITANCE, TRUE);
bc->SetData(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, TRUE);
var op = doc->GetFirstObject();
var res = SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, doc, op, bc, MODIFY_ALL);
if (res)
{
TextDialog("Seems to have worked.", DLG_OK);
EventAdd(EVENT_FORCEREDRAW);
}
else
{
TextDialog("Did not work.", DLG_OK);
}
}
This code works and creates a polygonized version of the first object in the scene, even if it's not selected. But there's something funny. The result object is inserted into the document automatically.
If I try creating a clone of the object first, then performing the modeling command, and then inserting the result object into the document, nothing gets polygonized. I just get a clone of the unchanged original object. Strange...
MyMenuPlugin::Execute(doc)
{
var bc = new(BaseContainer);
bc->SetData(MDATA_CURRENTSTATETOOBJECT_INHERITANCE, TRUE);
bc->SetData(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, TRUE);
var op = doc->GetFirstObject();
var clone = op->GetClone(CL_NO_HIERARCHY);
var res = SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, doc, clone, bc, MODIFY_ALL);
if (res)
{
TextDialog("Seems to have worked.", DLG_OK);
doc->InsertObject(clone, NULL, NULL);
EventAdd(EVENT_FORCEREDRAW);
}
else
{
TextDialog("Did not work.", DLG_OK);
}
}
So, you could in fact use the first code from this posting, and remove the newly created object (which also gets magically selected ;-) ) from the document and continue working with it. Cuold be faster than creating dummy documents etc..
Cheers,
Jack