Strange Crashing



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

    On 07/09/2009 at 08:18, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
       Hello,

    I am trying to get a command button to call a certain function. This is Tool plugin.

    Here's the code in the message() which looks for the command button to be clicked.

    > `

      
    \>  Bool SculptTool::Message(BaseDocument* doc, BaseContainer& data, LONG type, void* t_data)  
    \>  {  
    \>    
    \>  switch (type)  
    \>       {  
    \>            case MSG_DESCRIPTION_COMMAND:  
    \>            {  
    \>            DescriptionCommand *dc = (DescriptionCommand* ) t_data;  
    \>            if (dc->id[0].id==COMMAND_SUBDIVIDE)  
    \>                 {  
    \>                 GePrint("Subdivide Button Clicked");  
    \>                 ModelingCommandData mdat;  
    \>                 BaseContainer bc;  
    \>                 mdat.bc = &bc;  
    \>              DoCommand(mdat);  
    \>                 }  
    \>            }  
    \>       }  
    \>       return TRUE;  
    \>  }  
    \>  
    

    `

    Here's the code in the DoCommand()

    > `

      
    \>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
    \>  {  
    \>  GePrint("In DoCommand");  
    \>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
    \>    
    \>       //Define Variables  
    \>    
    \>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
    \>       if (!objPoly) return FALSE;  
    \>    
    \>    
    \>       //Determine Attributes  
    \>    
    \>       if (mdat.bc->GetBool(HYPERNURBS_SUBDIVISION, TRUE)) //If HyperNURBS is checked  
    \>       {  
    \>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); //Set HyperNURBS subdivision  
    \>       }  
    \>       else  
    \>       {  
    \>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, FALSE); //Disable HyperNURBS subdivision  
    \>       }  
    \>       mdat.bc->SetLong(MDATA_SUBDIVIDE_SUB, mdat.bc->GetLong(NUM_SUBDIVISIONS)); //Set Number of Subdivisions  
    \>       mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, mdat.bc->GetReal(MAX_ANGLE)); //Set Maxiumum Angle  
    \>              
    \>       //Subdivision Command  
    \>       SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
    \>       mdat.bc->SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());  
    \>         
    \>       return TRUE;  
    \>    
    \>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
    \>    
    \>    
    \>  }  
    \>  
    

    `

    For some reason, C4D crashes whenever I click the command button. I get the "GePrint" message that says "InCommand" so I know the problem is happening in the DoCommand(). Or at least I think that's where it's happening.

    Does anyone have any ideas as to what would be causing C4D to crash?

    Thanks,

    ~Shawn



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

    On 07/09/2009 at 09:09, xxxxxxxx wrote:

    This line probably points to an empty document pointer.

    PolygonObject *objPoly = ToPoly(mdat.doc- >GetActiveObject());

    Always check for valid pointers!

    Fill the ModelingCommandData with the current document.

    cheers,
    Matthias



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

    On 07/09/2009 at 09:18, xxxxxxxx wrote:

    would I do that with something like this?

    BaseDocument* doc;
         mdat.doc = doc;



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

    On 07/09/2009 at 09:27, xxxxxxxx wrote:

    No, in this case you would simply pass the doc from the Message function.

    > \> Bool SculptTool::Message(BaseDocument\* doc, BaseContainer & data, LONG type, void\* t_data) \> { \>      ... \>       \>      mdat.doc = doc; \>       \>      ... \> } \>

    cheers,
    Matthias



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

    On 07/09/2009 at 09:32, xxxxxxxx wrote:

    Awesome. Okay now it doesn't crash, but the problem now is.. it doesn't do anything. . LOL I still get the "In DoCOmmand" message, so it is doing the command. but none of the code in DoCommand() is executing?

    Any thoughts there?

    Thanks a lot Matthias.

    ~Shawn



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

    On 07/09/2009 at 10:36, xxxxxxxx wrote:

    Any thoughts on why it's not doing anything?

    Thanks,

    ~Shawn



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

    On 07/09/2009 at 11:45, xxxxxxxx wrote:

    Since SendModelingCommand() works on objects, you MUST specify the object in ModelingCommandData:

    mdat->op = objPoly;

    Otherwise it doesn't do anything, yes. :)



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

    On 07/09/2009 at 12:55, xxxxxxxx wrote:

    okay I did that and it still does nothing. :( Any thoughts? I added
    mdat->op = objPoly;

    Here's new code for DoCommand()

    > `

      
    \>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
    \>  {  
    \>  GePrint("In DoCommand");  
    \>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
    \>    
    \>       //Define Variables  
    \>    
    \>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
    \>       if (!objPoly) return FALSE;  
    \>       mdat.op = objPoly;  
    \>    
    \>       //Determine Attributes  
    \>    
    \>       if (mdat.bc->GetBool(HYPERNURBS_SUBDIVISION, TRUE)) //If HyperNURBS is checked  
    \>       {  
    \>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); //Set HyperNURBS subdivision  
    \>       }  
    \>       else  
    \>       {  
    \>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, FALSE); //Disable HyperNURBS subdivision  
    \>       }  
    \>       mdat.bc->SetLong(MDATA_SUBDIVIDE_SUB, mdat.bc->GetLong(NUM_SUBDIVISIONS)); //Set Number of Subdivisions  
    \>       mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, mdat.bc->GetReal(MAX_ANGLE)); //Set Maxiumum Angle  
    \>              
    \>       //Subdivision Command  
    \>       SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
    \>       mdat.bc->SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());//Shows the current polygon count  
    \>    
    \>         
    \>       return TRUE;  
    \>    
    \>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
    \>       GePrint("End Of DoCommand");  
    \>    
    \>  }  
    \>  
    

    `



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

    On 07/09/2009 at 13:57, xxxxxxxx wrote:

    Have you checked the values being set in mdat, especially MDATA_SUBDIVIDE_SUB? This must be >0. mdat.mode should be MODIFY_ALL.



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

    On 07/09/2009 at 14:36, xxxxxxxx wrote:

    okay nothing happens when I click the button. But something very weird happens when I click the button and then resize the viewport frame. I click the button, nothing happens, then I resize the viewport frame and suddenly the cube in my viewport subdivides. But not by the number that is in the LONG NUM_SUBDIVISIONS. I am not sure where it is getting this number from ..

    Here's the code I have in DoCommand().

    Thanks for your help.

    > `

      
    \>  Bool SculptTool::DoCommand(ModelingCommandData &mdat;)  
    \>  {  
    \>  GePrint("In DoCommand");  
    \>  //CODE RELATED TO THE SUBDIVISION OPTIONS/////////////////////////////////  
    \>    
    \>       //Define Variables  
    \>    
    \>      PolygonObject *objPoly = ToPoly(mdat.doc->GetActiveObject());  
    \>       if (!objPoly) return FALSE;  
    \>       mdat.op = objPoly;  
    \>       mdat.mode = MODIFY_ALL;  
    \>    
    \>       //Determine Attributes  
    \>    
    \>       if (mdat.bc->GetBool(HYPERNURBS_SUBDIVISION, TRUE)) //If HyperNURBS is checked  
    \>       {  
    \>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); //Set HyperNURBS subdivision  
    \>       }  
    \>       else  
    \>       {  
    \>       mdat.bc->SetBool(MDATA_SUBDIVIDE_HYPER, FALSE); //Disable HyperNURBS subdivision  
    \>       }  
    \>       mdat.bc->SetLong(MDATA_SUBDIVIDE_SUB, mdat.bc->GetLong(NUM_SUBDIVISIONS); //Set Number of Subdivisions  
    \>       mdat.bc->SetReal(MDATA_SUBDIVIDE_ANGLE, mdat.bc->GetReal(MAX_ANGLE)); //Set Maxiumum Angle  
    \>              
    \>       //Subdivision Command  
    \>       SendModelingCommand(MCOMMAND_SUBDIVIDE, mdat);  
    \>       mdat.bc->SetLong(POLYGON_COUNT, objPoly->GetPolygonCount());//Shows the current polygon count  
    \>    
    \>         
    \>       return TRUE;  
    \>    
    \>  //END SUBDIVISION OPTIONS/////////////////////////////////////////////////  
    \>       GePrint("End Of DoCommand");  
    \>    
    \>  }  
    \>  
    

    `

    Weird huh?


Log in to reply