Search code examples
pythonmaxscript

The maxscript function "WM3_MC_BuildFromNode" in Python


I used the following code based on the information given in help.autodesk.com for executing maxscript in Python:

import MaxPlus
test = MaxPlus.FPValue()
#The target node has only one morpher and I want to retrieve it using
# .morpher[1]
bool = MaxPlus.Core.EvalMAXScript("WM3_MC_BuildFromNode $node.morpher[1] 1 $target", test)
print bool

If I print the boolean, this always print: "false". However the following code works (aka the print statement returns true):

import MaxPlus
test = MaxPlus.FPValue()
#The target node has only one morpher
bool = MaxPlus.Core.EvalMAXScript("WM3_MC_BuildFromNode $node.morpher 1 $target", test)
print bool

However I cannot use the latter code since it must be possible in my code that a node has multiple morphers. Is there a better way using the Python api for maxscript (I didn't find a method) or can anyone give suggestions how the first code can be improved.

Thank you


Solution

  • The solution to my problem is:

    MaxPlus.Core.EvalMAXScript(WM3_MC_BuildFromNode(for mod in $node.modifiers where isKindOf mod Morpher collect mod)[1] 3 $target)
    

    This solution is found by Swordslayer on the autodesk forum for 3ds Max