Easier Way to Modify Pose Morph Strength Based on Name?
-
Hi,
I can modify the pose morph strength based on name through the following code:
import c4d def main(): morph_name = "smile_wide_L" morph_value = 0.8 for i in range( morph_tag.GetMorphCount()): descID = tag.GetMorphID(i) if tag.GetMorph(i).GetName()==morph_name: tag[descID] = morph_value c4d.EventAdd()
As you can see, it has to loop through several times to get to the actual morph target to be modified.
Other DCC API just simply do a variation of this:
morph_object.morph_name = morph_valueIs there a better way of doing this?
-
Hi @bentraje,
Pose morph name is not a unique identifier, meaning that you can theoretically have multiple pose morphs with the same name (even though it doesn't sound practical). Hence you cannot access pose morph in the tag by its name because such indexing is ambiguous.
If you're sure there're no pose morphs with the same name, then you can create a dictionary that maps pose morph names to its DescIDs and use that instead.
Cheers,
Ilia -
@i_mazlov
Ah yes, my pose morph names are standardized so there should be no duplicated/redundant names.
And yea, thanks for mentioning the dictionary route. Totally overlooked that.
That could indeed be an easier way to set/get some values.Thanks!