THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 04/01/2010 at 15:09, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11
Platform: Windows ;
Language(s) : C++ ;
---------
I had previously set up my plugin to remove all connected materials when the object is deleted by using the Free() member function. THe code that I have in the Free() is ...
void Planet::Free(GeListNode* node)
{
GePrint("FREE");
BaseObject* op = static_cast<BaseTag*>(node)->GetObject();
if (!op) goto BYPASS;
BaseObject* prnt = op->GetDocument()->GetActiveObject();
if (!prnt) goto BYPASS;
BaseDocument* doc = op->GetDocument();
if (!doc) goto BYPASS;
doc->StartUndo();
//Remove Materials when Object is deleted
if (prnt)
{
TextureTag* surfaceTag = (TextureTag* )(prnt->GetDown()->GetFirstTag());
if (!surfaceTag) goto BYPASS;
TextureTag* lightTag = (TextureTag* )(prnt->GetDown()->GetFirstTag()->GetNext());
if (!lightTag) goto BYPASS;
TextureTag* cloudTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetFirstTag());
if (!cloudTag) goto BYPASS;
TextureTag* atmTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetNext()->GetFirstTag());
if (!atmTag) goto BYPASS;
if (prnt->GetDown()->GetNext()->GetNext()->GetNext()->GetNext()->GetDown())
{
TextureTag* ringTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetNext()->GetNext()->GetNext()->GetDown()->GetFirstTag());
BaseMaterial* rMat = ringTag->GetMaterial();
if (!rMat) goto BYPASS;
rMat->Remove();
BaseMaterial::Free(rMat);
}
BaseMaterial* sMat = surfaceTag->GetMaterial();
if (!sMat) goto BYPASS;
sMat->Remove();
BaseMaterial::Free(sMat);
BaseMaterial* lMat = lightTag->GetMaterial();
if (!lMat) goto BYPASS;
lMat->Remove();
BaseMaterial::Free(lMat);
BaseMaterial* cMat = cloudTag->GetMaterial();
if (!cMat) goto BYPASS;
cMat->Remove();
BaseMaterial::Free(cMat);
BaseMaterial* aMat = atmTag->GetMaterial();
if (!aMat) goto BYPASS;
aMat->Remove();
BaseMaterial::Free(aMat);
}
doc->EndUndo();
BYPASS:;
}
However, I have run in to a snag. This code works great for removing the materials when the object is deleted, however, when the user does an undo, it also calls the Free() and removes all of the materials when it is not suypposed to. Is there a way to avoid this from happening? Does anyone have any ideas how I can test to see if the reason the plugin is entering in to the Free() is because of an UNDO . and if so, skip over the r emove code?
Thanks in advance.
~Shawn