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:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
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.
Bool broken = bc->GetBool(PXG_ROCK_BREAK_ENABLE);
Real bradius = bc->GetReal(PXG_ROCK_BREAK_RADIUS);
LONG borigin = LONG(bc->GetReal(PXG_ROCK_BREAK_ORIGIN));
if(borigin < pointCount)
borigin = borigin;
borigin = (pointCount - 1);
if(bradius < polyObj->GetRad().x * 2)
bradius = bradius;
bradius = ((polyObj->GetRad().x * 2) - 1);
BaseSelect *bs = polyObj->GetPointS();
if (!mod || !mod->InitObject(polyObj)) return FALSE;
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)
//Commit Modeling Changes
if (!mod->Commit(polyObj, MODELING_COMMIT_NO_NGONS , NULL))
for(int i = 0; i < pointCount; i++)
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?
On 16/07/2011 at 11:57, xxxxxxxx wrote:
Unless you want an incremental set of undos (and you will be at the mercy of the user setting for Undo Levels!), you should enclose all of the AddUndo() calls in a single set of StartUndo()+EndUndo() to make one undo for all of the DoUndo() calls. In other words, put the StartUndo()+EndUndo() outside of the loop. Also, you have possible returns without calling doc->EndUndo(). Bad. That is why it is better to have them bracket a function so that this situation cannot occur.
Also, you cannot call DoUndo() before EndUndo()!! To do that, do this:
if (!commit) doc->DoUndo();
On 16/07/2011 at 12:13, xxxxxxxx wrote:
So in the code I posted above where would you put the StartUndo() and EndUndo() would you put it on either side of the function containing this code.. so at the beginning and end of the whole function? Or directly in front of and behind the DoUndo?
Or better yet.. In the GetVirtualObjects function that calls this one?
On 16/07/2011 at 12:16, xxxxxxxx wrote:
I just noticed that you had the DoUndo() call before the EndUndo(). Can't be done that way. The process is:
AddUndo(); // n number of times
// At some time after EndUndo() is called - this could be the user hitting Ctrl-Z which is handled by C4D - or:
if (condition) DoUndo();
On 16/07/2011 at 12:17, xxxxxxxx wrote:
Ah.. okay .. thanks Robert.. I will mess with it some more.
On 22/07/2011 at 05:05, xxxxxxxx wrote:
Why would you create undos in GetVirtualObjects?