MAXScript - 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.

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.

Yes being an expert in MXS entails having a checklist of things to try when something doesn’t work:

Does the modify panel need to be open, does the object need to be selected (and the modify panel open), does the screen need to be redrawn, and any other number of heinous things.

[QUOTE=Rob Galanakis;13976]Yes being an expert in MXS entails having a checklist of things to try when something doesn’t work:

Does the modify panel need to be open, does the object need to be selected (and the modify panel open), does the screen need to be redrawn, and any other number of heinous things.[/QUOTE]

Ah, thanks for the tips. It was only by chance that I left the object selected and saw that it worked. Quite odd behaviour.

Just don’t forget to comment the code!

1 Like