THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/11/2010 at 13:58, xxxxxxxx wrote:
main.cpp
Bool PluginStart()
{
...
// Greebler Demo or Registered
if (kdzSerial) greebler = RegisterGreebler(network, kdzSerial->mode, kdzSerial->time);
// Cinema 4D Demo
else greebler = RegisterGreebler(network, 3, 2147483647L);
...
return TRUE;
}
Greebler.cpp
// *** ****
// Global Registrant Method for Greebler Command plugin
//*---------------------------------------------------------------------------*
Greebler* RegisterGreebler(const Bool& network, const UCHAR& mode, const LONG& time)
//*---------------------------------------------------------------------------*
{
Greebler* gree = gNew Greebler();
if (!gree) return NULL;
#ifdef C4D_R12
if (RegisterCommandPlugin(ID_GREEBLER, String("Greebler Library Manager"), 0L, AutoBitmap("greebler.tif"), String("Greebler Library Manager"), gree))
{
if (gree->Init(network, mode, time)) return gree;
}
#else
if (RegisterCommandPlugin(ID_GREEBLER, String("Greebler Library Manager"), 0L, String("greebler.tif"), String("Greebler Library Manager"), gree))
{
if (gree->Init(network, mode, time)) return gree;
}
#endif
return NULL;
}
// Greebler.Init
// - Initialize arrays, stock objects, and custom objects
//*---------------------------------------------------------------------------*
Bool Greebler::Init(const Bool& t_network, const UCHAR& t_mode, const LONG& t_time)
//*---------------------------------------------------------------------------*
{
network = t_network;
mode = t_mode;
time = t_time;
// Get Library folder from C4D Prefs container
if (!GetDataFolder()) return ErrPrt("Greebler.Greebler.Init.GetDataFolder() failed!");
// Allocate Copy Array
copy_array = AtomArray::Alloc();
if (!copy_array) return ErrPrt("Greebler.Greebler.Init.copy_array failed!");
// Allocate Stock Shape Array
array_stock = AtomArray::Alloc();
if (!array_stock) return ErrPrt("Greebler.Greebler.Init.array_stock failed!");
// Load Shape objects into Arrays (memory)
if (network) return TRUE;
if (!LoadStockLibrary()) return FALSE;
// Return if NET Client or Server
if (network) return TRUE;
// Create Custom Shape and Nurnie Libraries
Filename fn = Filename(datafolder)+Filename(GeLoadString(GRES_LIB_CUSTOMSHAPES));
if (!library_shape.Init(fn, "ggicon")) return FALSE;
fn = Filename(datafolder)+Filename(GeLoadString(GRES_LIB_CUSTOMNURNIES));
if (!library_nurnie.Init(fn, "gnicon")) return FALSE;
if (!LoadShapeLibrary()) return FALSE;
if (!LoadNurnieLibrary()) return FALSE;
return TRUE;
}
// Greebler.LoadStockLibrary
//*---------------------------------------------------------------------------*
Bool Greebler::LoadStockLibrary()
//*---------------------------------------------------------------------------*
{
// Get .c4d files in this folder
Filename path = GeGetPluginPath()+Filename("res")+Filename("StockShapes");
if (!LoadItem(path, "Cube.c4d")) return FALSE;
if (!LoadItem(path, "T.c4d")) return FALSE;
if (!LoadItem(path, "L.c4d")) return FALSE;
if (!LoadItem(path, "C.c4d")) return FALSE;
if (!LoadItem(path, "H.c4d")) return FALSE;
if (!LoadItem(path, "D.c4d")) return FALSE;
if (!LoadItem(path, "Box.c4d")) return FALSE;
if (!LoadItem(path, "CubeCC.c4d")) return FALSE;
if (!LoadItem(path, "OblongOctagon.c4d")) return FALSE;
return TRUE;
}
// Greebler.LoadItem
//*---------------------------------------------------------------------------*
Bool Greebler::LoadItem(const Filename& path, const Filename& file)
//*---------------------------------------------------------------------------*
{
// Insert Stock Library Object(s)
BaseDocument* doc = LoadDocument(path+file, SCENEFILTER_OBJECTS, NULL);
if (!doc)
{
MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+") failed!");
return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+") failed!");
}
BaseObject* op = doc->GetFirstObject();
if (!op)
{
KillDocument(doc);
MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+").op failed!");
return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+").op failed!");
}
BaseObject* cop = static_cast<BaseObject*>(op->GetClone(COPYFLAGS_0, NULL));
if (!cop)
{
KillDocument(doc);
MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+").cop failed!");
return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+").cop failed!");
}
//op->Remove();
if (!array_stock->Append(cop))
{
KillDocument(doc);
MessageDialog("Greebler.Greebler.LoadItem("+file.GetString()+").array_stock.Append() failed!");
return ErrPrt("Greebler.Greebler.LoadItem("+file.GetString()+").array_stock.Append() failed!");
}
KillDocument(doc);
return TRUE;
}
Note that the failure occurs in LoadItem(), but, despite checking every possible error, none of the MessageDialog()s is displayed.