THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/07/2011 at 09:05, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Hey everyone,
I am wondering if it is possible to determine the number of actions that have happened while running some modeling commands.. Here's the code I am using. :)
//==========================================================//
doc->StartUndo();
Bool broken = bc->GetBool(PXG_ROCK_BREAK_ENABLE);
if(broken)
{
Real bradius = bc->GetReal(PXG_ROCK_BREAK_RADIUS);
LONG borigin = LONG(bc->GetReal(PXG_ROCK_BREAK_ORIGIN));
if(borigin < pointCount)
{
borigin = borigin;
}
else
{
borigin = (pointCount - 1);
bc->SetReal(PXG_ROCK_BREAK_ORIGIN, borigin);
}
if(bradius < polyObj->GetRad().x * 2)
{
bradius = bradius;
}
else
{
bradius = ((polyObj->GetRad().x * 2) - 1);
bc->SetReal(PXG_ROCK_BREAK_RADIUS, bradius);
}
BaseSelect *bs = polyObj->GetPointS();
AutoAlloc<Modeling> mod;
if (!mod || !mod->InitObject(polyObj)) return FALSE;
//GePrint(LongToString(mod->GetLastError(polyObj)));
for (int i = 0; i < pointCount; i++)
{
if(mod->IsValidPoint(polyObj, i) && !mod->IsPointDeleted(polyObj, i))
{
Vector disVec = points[i] - points[borigin];
Real distance = Len(disVec);
if(distance <= bradius)
{
bs->Select(i);
mod->MeltPoint(polyObj, i);
}
}
}
//Commit Modeling Changes
if (!mod->Commit(polyObj, MODELING_COMMIT_NO_NGONS , NULL))
{
for(int i = 0; i < pointCount; i++)
{
doc->DoUndo(TRUE);
}
return FALSE;
}
}
doc->EndUndo();
//===========================================================//
essentially what I am doing here is looping through the points and deleting points within a radius from the origin point. The problem I keep running in to is that sometimes the commit happens when the points are not in a valid state.. so I know that I am not doing enough undos if commit fails.. Is is possible to determine the number of undos that have been added?
Thanks,
Shawn