THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/06/2008 at 09:27, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10
Platform: Windows ;
Language(s) : C++ ;
---------
Hi. I'm still trying to write some code in c++, which creates a cube and extrude one side. Finally I managed to write the code so it doesn't crash any more, but there is still no extruded cube in Cinema 4d. Instead there's only an object which seems to be empty.
Here's the code:
BaseObject* extrudierterWuerfel::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)
{
BaseDocument *doc = op->GetDocument();
BaseDocument *copydoc=doc->Alloc();
BaseObject *cloned = BaseObject::Alloc(Ocube);
PolygonObject *poly=NULL;
copydoc->InsertObject(cloned,NULL,NULL,FALSE);
copydoc->InsertObject(poly,NULL,NULL,FALSE);
ModelingCommandData cd,cd2,cd3;
cd.doc = copydoc;
cd.op = cloned;
if (!SendModelingCommand(MCOMMAND_MAKEEDITABLE, cd)) return NULL;
poly=static_cast<PolygonObject*>(cd.result->GetIndex(0));
copydoc->SetMode(Mpolygons);
//Select all
ModelingCommandData cd1;
cd1.doc = copydoc;
cd1.op = poly;
cd1.mode = MODIFY_POLYGONSELECTION;
if (!SendModelingCommand(MCOMMAND_SELECTALL, cd1)) GePrint("could not select all");
GePrint("Selektion geschafft!");
BaseContainer bc;
bc.SetData(MDATA_EXTRUDE_OFFSET, 50);
ModelingCommandData extrusionmcd;
extrusionmcd.bc=&bc;
extrusionmcd.doc=copydoc;
extrusionmcd.op=poly;
extrusionmcd.mode=MODIFY_ALL;
poly=ToPoly(SendModelingCommand(ID_MODELING_EXTRUDE_TOOL, extrusionmcd));
return poly;
}
To make a guess: Is it maybe because poly=static_cast<PolygonObject*>(cd.result->GetIndex(0)); only assigns a little something, not the whole cube?
Another problem I have is, that "Unable to open file *.res" appears everytime I run the plugin. Is it possible that this causes my problem? How do I make such a *.res-file?
Thanks
Basti