How to set Morpher by key name with script?

How to set Morpher by key name with script?

YASUSHI_EMOTO
Enthusiast Enthusiast
499 Views
1 Reply
Message 1 of 2

How to set Morpher by key name with script?

YASUSHI_EMOTO
Enthusiast
Enthusiast

I am creating a script to set the value of Morpher.

If I write the following code, I can set all Morpher to 100.

 

mph=$.morpher
for i = 1 to 100 do (
 mph[i].value = 100
)

 

However, I do not want to set all values to 100.
I want to set the value of mouthOpen to 30, and the value of mouthSmile to 60, and so on.

 

And if I create the following code, there will be 100 loops each time, even though I have only set up 2 Morpheres.

I want to reduce the number of loops in order to create a faster code.
Is there anything I can do?

 

mph=$.morpher
for i = 1 to 100 do (
  if "mouthOpen" == WM3_MC_GetName mph i then
  {
   mph[i].value = 30
  }
  if "mouthSmile " == WM3_MC_GetName mph i then
  {
   mph[i].value = 60
  }
)

0 Likes
Accepted solutions (1)
500 Views
1 Reply
Reply (1)
Message 2 of 2

10DSpace
Advisor
Advisor
Accepted solution

@YASUSHI_EMOTO 

 

The maxscript property,  WM3_MC_HasData provides a  way for you to only loop through morph channels which contain data.

 

So substituting the following conditional for loop for your current for loop should do what you are asking:

for i = 1 to 99 where (WM3_MC_HasData mph i == true) do

 

0 Likes