Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Invalid kernel State

    Scheduled Pinned Locked Moved SDK Help
    7 Posts 0 Posters 525 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        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.

        doc->StartUndo()
        MyLoopyFunction();
        doc->EndUndo();

        Also, you cannot call DoUndo() before EndUndo()!!  To do that, do this:

        doc->StartUndo()
        MyLoopyFunction();
        doc->EndUndo();
        if (!commit) doc->DoUndo();

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          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?

          Thanks,

          Shawn

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 16/07/2011 at 12:13, xxxxxxxx wrote:

            Or better yet..   In the GetVirtualObjects function that calls this one?

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              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:

              StartUndo();
              AddUndo(); // n number of times
              EndUndo();
              // At some time after EndUndo() is called - this could be the user hitting Ctrl-Z which is handled by C4D - or:
              if (condition) DoUndo();

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 16/07/2011 at 12:17, xxxxxxxx wrote:

                Ah.. okay ..  thanks Robert..  I will mess with it some more.  🙂

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 22/07/2011 at 05:05, xxxxxxxx wrote:

                  Why would you create undos in GetVirtualObjects?

                  cheers,
                  Matthias

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post