MaxScript - SkinWrap not Updating when Required

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to automate a procedure I use to copy morphers across slightly different meshes.
The steps involve applying a morph modifier with all targets to the previously working mesh. Bring the newer mesh and align in on top of the previous. Ensure all morphers are set to 0, and then apply a Skinwrap with the vertex deformation engine. When incrementing the morph slider on the older mesh, the newer mesh will trace the final position of the vertices as well - I can then collapse the whole stack and use it as a target for the newer mesh.
I replicated the whole procedure in a script, but in the end result, the new targets do not deform due to the effects of the skinwrap, I am almost certain it is because the viewport is not refreshed - and hence, the effects of skinwrap are neglected in code.
-- The Primary Loop; iterate over all morph targets, duplicate a base mesh, -- position it relative to previous base mesh, reset all morph sliders to 0%, -- and apply skin wrap. Set the appropriate morph target to 100%, and collapse the -- duplicate mesh and set it aside. Repeat for all other morph targets. for i = 1 to morphers.count do ( newTarget = copy targetBaseModel newTarget.name = morphers[i].name -- Position the Models on top of each other PositionModel newTarget prevBaseModel morphModifier = prevBaseModel.modifiers["morpher"] -- Set the Morpher to 0% WM3_MC_SetValue morphModifier i 0.0 -- SkinWrap skinwrapMod = Skin_Wrap() addModifier newTarget skinwrapMod skinwrapMod.engine = 1 -- VertexDeformation skinwrapMod.falloff = 0.001 skinwrapMod.distance = 0.001 skinwrapMod.meshList = append skinwrapMod.meshList(prevBaseModel) -- Set Morpher to 100% WM3_MC_SetValue morphModifier i 100.0 -- The new target mesh should have the same final shape as the base, -- collapse the new target and set it aside CollapseStack newTarget move newTarget [0,50*i,0] -- Set the Morpher back to 0% for the next iteration WM3_MC_SetValue morphModifier i 0.0 ) -- Delete the temporary morph modifer deleteModifier prevBaseModel 1 )
Is there a method to ensure the viewport updates the changes before proceeding to the next line of code?
Here are the results of the script for context
The setup -- attempting to recreate the 3 morph targets for the "new" mesh
The resulting morph targets appear unchanged from the base model. They must look like the other 3 morph targets if they were skinwrap deformed correctly!