Notifications
Clear all

[Closed] morpher target problem

the morpher modifier page have “extract” button, how to implement this action in script?

3 Replies

you could simply set all channels but the one you want to extract to value 0,
and the channel you want to extract to 100. Then make a snapshot.

here is a function that extracts specified channel data…


fn extractTarget modi: channel:1 = 
(
	if modi == unsupplied do modi = modpanel.getcurrentobject()
	if IsValidMorpherMod modi do
	(
		if isvalidnode (node = refs.dependentnodes (refs.dependents modi immediateOnly:on)[1] firstonly:on) do
		(
			if WM3_MC_IsValid modi channel do
			(
				if WM3_MC_HasTarget modi channel then (WM3_MC_GetTarget modi channel)
				else if WM3_MC_HasData modi channel do
				(
					active = for ch=1 to modi.numsubs where ch != channel and WM3_MC_IsValid modi ch and WM3_MC_IsActive modi ch collect
					(
						WM3_MC_SetActive modi ch off
						ch
					)
					act = WM3_MC_IsActive modi channel
					val = WM3_MC_GetValue modi channel 
					name = WM3_MC_GetName modi channel 
					
					WM3_MC_SetActive modi channel on
					WM3_MC_SetValue modi channel 100.0
					
					target = copy node name:name
					collapsestack target
					
					WM3_MC_SetActive modi channel act
					WM3_MC_SetValue modi channel val

					for ch in active do WM3_MC_SetActive modi ch on 
					WM3_RefreshChannelParamsUI modi
					
					target
				)
			)
		)
	)
)	

but… the function is not complete. Anyone is free to show the problem and complete the function…

also… there is another way how to extract the data. and it’s more elegant than shown above.