Notifications
Clear all

[Closed] script controller, via script

hey guys, me again with some more questions, I hope someone can shed some light over here!
so i have object “A” with a morpher modifier, this has targets “B” and “C” loaded in the morpher in channel 1 and 2. Now I’ve created another target “B_C”, I’ve added it to the morpher too on channel 3, but i want the weight of this to be driven by the minimum weight between A and B, untill now I used the amin (a b ) as an expression controller and that did the trick, but now I want this weight “B_C” to be affected by more than 2 weights so i need to use script controller. I know how to do it by hand as is the same as the expression controller for this case, but I wanna automate this via script but ‘m having problems with how to set the expression in maxscript.
The main problem is that I have to declare a variable per track ( per channel that I want to affect the weight on “B_C” which are channels “B” and “C” in this case, and then I need to write the actual expression…this is what I got so far, excuse the code as is a bloody mess…

chop = filterstring $.name "_"
master = $body
channelsForProgressive = #()


for i = 1 to 100 do
(
	if WM3_MC_HasData master.morpher i then 
	(
		for c = 1 to chop.count do
		(
			if chop[c] == WM3_MC_GetName master.morpher i do
			(
				append channelsForProgressive i
			)
			
		)
	)
)


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TO KNOW IF WHAT IS THE LATEST AVAILABLE CHANNEL IN THE MORPHER:


emptyChannels = #()
for n = 1 to 100 do
(
	if WM3_MC_HasData master.morpher n == false do
	(
		appendIfUnique emptyChannels n
	)
)
sort emptyChannels

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ADDS THE SELECTED OBJECT AS A MORPH TARGET IN THE FIRST EMPTY CHANNEL AVAILABLE AND ADDS SCRIPT CONTROLLER:

correctiveController= float_script()
WM3_MC_BuildFromNode master.morpher emptyChannels[1] $

for n = 1 to 100 do
(
	if WM3_MC_HasData master.morpher n == false do
	(
		appendIfUnique emptyChannels n
	)
)
sort emptyChannels
$body.morpher[emptyChannels[1]].controller = correctiveController

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--CREATES THE VARIABLES FOR THE EXPRESSION:

vars = #()
for var in 1 to chop.count do
(
	thevar = correctiveController.addtarget chop[var] $body.morpher[channelsForProgressive[var]].controller
	append vars thevar
)
correctiveController.SetExpression  amin

as you can see, the last part to create the variables is just wrong and not working, the rest seems to be sort of working fine…

thanks for the help guys
Alex