WM3_MC_BuildFromNode not working with button press?

Hey folks, I've got a pretty simple piece of code that doesn't seem to be behaving as expected at all. After a couple of hours of head scratching I thought I'd seek help.

Here's the script:

 on bigBtn pressed do
 (
 originalMesh = $originalBox
 newMesh = $newBox
 originalMeshCheck = copy originalMesh
 compatibilityCheck = (Morpher())
 addModifier newMesh compatibilityCheck
 WM3_MC_BuildFromNode compatibilityCheck 1 originalMeshCheck
 --Then there'd be an if statement to check if morph data present
 )

I've put the first two variables as hardcoded, but they are grabbed via a pick button.

So it's a pretty simple script, but at the end of it I'm left with the newMesh having a morph target and no data.

What's SUPER confusing is that if I just run this without a button press, just that code on its own, it works flawlessly.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mackinder's picture

Okay I fixed it. Essentially

Okay I fixed it.

Essentially before I add the morph target I have to select the object.

Makes no sense; I shouldn't have to select it; it works if I manually run that single line without it selected - but in the script it needs to be selected.

Moral of the story: MAXScript makes no sense sometimes.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.