Notifications
Clear all

[Closed] C++ Modifiers Turn on/off

Hi, I am trying to create a button that will either turn off/on the modifiers off selected Nodes. I know there is the Modifier Class with the Disable and Enable. But I can find anything that allows you to find the Mods on a Node with that class. Do I need to use that class or is there a different way of collecting the Mods and turning them off/on ??

5 Replies
 lo1

Modifiers don’t exist on an INode, they exist on an Object.
Read the documentation for IDerivedObject to see how to access the modifier stack.

from
http://dl3d.free.fr/resources/3DSMAX_SDK_DavidLanier.pdf


 void ScanModsFromNode(INode* node){
 	if (! node)return;
 
 	Object *obj = node->GetObjectRef();
 	IDerivedObject *D_obj = NULL;
 	Modifier *sm = NULL;
 	ModContext* mc = NULL;
 
 	if (obj->SuperClassID() == GEN_DERIVOB_CLASS_ID){
 		D_obj = static_cast<IDerivedObject *> (obj);
 	}
 	else{
 		D_obj = CreateDerivedObject();
 		D_obj->TransferReferences(obj);
 		D_obj->ReferenceObject(obj);
 	}
 	const int NumMods = D_obj->NumModifiers();
 	for(int i = 0; i < NumMods; i++){
 		Modifier *tMod = D_obj->GetModifier(i);
 		if (! tMod) continue;
 		MSTR ModName = tMod->GetName();
 		const Class_ID& cid = tMod->ClassID();
 		ModContext* mc = D_obj->GetModContext(i);
 	}
 }
 

I have found how to delete all modifiers but not your turn off and on

here is delete all mods, it should get you closer to what you need


 void DeleteModsFromNode(INode* node){
 	if (! node)return;
 
 	Object *obj = node->GetObjectRef();
 	IDerivedObject *D_obj = NULL;
 
 	if (obj->SuperClassID() == GEN_DERIVOB_CLASS_ID){
 		D_obj = static_cast<IDerivedObject *> (obj);
 	}
 	else{
 		D_obj = CreateDerivedObject();
 		D_obj->TransferReferences(obj);
 		D_obj->ReferenceObject(obj);
 	}
 	const int NumMods = D_obj->NumModifiers();
 	for(int i = 0; i < NumMods; i++){
 		D_obj->DeleteModifier(0);
 	}
 }
 
Modifier *tMod = D_obj->GetModifier(i);
 tMod->EnableMod();
 tMod->DisableMod();
 

I just had it! But you got there first


 void DisableModFromNode(INode* node){
 	if (! node)return;
 
 	Object *obj = node->GetObjectRef();
 	IDerivedObject *D_obj = NULL;
 
 	if (obj->SuperClassID() == GEN_DERIVOB_CLASS_ID){
 		D_obj = static_cast<IDerivedObject *> (obj);
 	}
 	else{
 		D_obj = CreateDerivedObject();
 		D_obj->TransferReferences(obj);
 		D_obj->ReferenceObject(obj);
 	}
 	const int NumMods = D_obj->NumModifiers();
 	for(int i = 0; i < NumMods; i++){
 		Modifier *tMod = D_obj->GetModifier(i);
 		tMod->DisableMod();  // or tMod->EnableMod();
 	}
 }