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