Notifications
Clear all

[Closed] Remove certain Morpher track/curve keys in maxscript

Using Morpher-driven expression animation, I want to delete certain track keys (selected according to the string prefix feature) before exporting. Haven’t found the right way to do this.

I also didn’t find how to change the name of a track in Morpher. T_T

I’m not very good at maxscript development. I recently encountered these two problems when writing scripts. I searched for some posts and help documents, but I haven’t solved them. I really hope you can give me some pointers.
image

3 Replies

let’s do it task by task:

#1 – delete keys of currently selected trackview tracks:

fn getSelectedTracks =
(	
	if (tv = trackviews.current) == undefined then #() else for k=1 to tv.numSelTracks() collect (tv.getSelected k)
)
deletekeys (getSelectedTracks())

now is about to rename:

(
	morph_modifier = $.morpher
	morph_channel = 2 
	channel_2_name = WM3_MC_GetName morph_modifier morph_channel
	WM3_MC_SetName morph_modifier morph_channel (channel_2_name + ".new")
	--WM3_MC_GetName morph_modifier morph_channel
)

see mxs help > Morpher : Modifier

Thanks a lot for the reply denisT:beers:, I solved this problem by testing WM3_MC before, but forgot to reply to this thread to indicate the status. I didn’t know much about Morpher : Modifier before and these are the two functions I ended up with.

fn delMorphChannelCurve model targetName InvertBool =
(
	if model != undefined do 
	(
		mo = model.modifiers[#morpher]
		for i=1 to 100 do
		(
	  		Morphname = (WM3_MC_GetName mo i)
	  		ctrl = mo[i].controller
	  		if findstring Morphname targetName != undefined do
	  		(
	  			if ctrl!= undefined do
	  			(
	    			deleteKeys ctrl
	   			)
	  		)
	 	)
	 	WM3_RebuildInternalCache mo
		WM3_RefreshChannelListUI mo
		WM3_RefreshChannelParamsUI mo
	)
)


fn renameMorphChannel model targetName renameStr =
(
	if model != undefined do 
	(
		mo = model.modifiers[#morpher]
		for i=1 to 100 do
		(
  			Morphname = (WM3_MC_GetName mo i)
  			ctrl = mo[i].controller
  			
  			if findstring Morphname targetName != undefined do
  			(
  				
  				if ctrl!= undefined do
  				(
    				 WM3_MC_SetName mo i renameStr
   				)
  			)
 		)
		WM3_RebuildInternalCache mo
		WM3_RefreshChannelListUI mo
		WM3_RefreshChannelParamsUI mo
	)	
)