|
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’ve tried putting this into a function and calling it:
fn checkTopology originalMesh newMesh =
(
--2.Check if meshes are compatible
--Copy original mesh and delete morpher
originalMeshCheck = copy originalMesh
deleteModifier originalMeshCheck 1
--define modifier
compatibilityCheck = (Morpher())
--add modifier to new mesh and check if it's compatible with the original mesh
addModifier newMesh compatibilityCheck
WM3_MC_BuildFromNode compatibilityCheck 1 originalMeshCheck
)
And then I just call that function when the button is pressed and pass off the object, but it still doesn’t work.
|
|
|
|
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.
|
|
|