For decompiling FLEXES and getting them into 3DS Max ready format:

  1. Create a dmx_<CLASSNAME>.lua file with the following:

    This assumes your directory structure is set up like so:
    /decomp/CLASS_NAME/ <-- core directory for your decompiled smd
    /decomp/CLASS_NAME/flexes <-- your starting dmx files will go here
    /decomp/CLASS_NAME/flexes/CLASS_NAME <-- flexes will go here
    /decomp/CLASS_NAME/flexes/CLASS_NAME/hwm <-- SFM high morph flexes will go here
  2. Place this in steam\steamapps\ACCOUNT_NAME\sourcesdk\bin\orangebox\bin
  3. Make sure the above folder structure exists!
  4. Make sure the vs.lua file is blank; create a vs.lua file if one does not exist
  5. Make sure you're using the dmx files (NOT the dmx.smd files) located in \sourcesdk_content f\modelsrc\player\CLASS_NAME\parts\dmx
  6. SHIFT + RIGHT CLICK on bin\orangebox\bin, choose 'open command window here'
  7. Type in the following and wait a few moments:
    dmxedit dmx_<CLASSNAME>.lua
  8. Flex files should be in their respective folder
  9. Make sure the files are there. You can safely ignore errors about a library failing to load, but if you see SteamStartup failed, you'll need to restart steam and try again.
  10. GOTCHAS: If you get the error 'AppFramework : Unable to load module p4lib.dll!' make sure you're using the right dmx files. Alternately, try running dmxedit with -nop4 (tools mode) enabled., or simply click and drag the .lua file onto the dmxedit executable.
  11. Next, delete all 'mixed' flexes by searching in Explorer for:
  12. Once you have deleted the mixed flexes, you'll need to run the 'Fix Obj Names.exe' file in both folders to correct the name.
  13. Files are ready to import! Create a layer in 3ds Max called 'morphs_LOW' and use the batchloader_19 importer script to import them.
  14. Hide all the other layers in Max and select everything in the morphs layer except for the head. Delete.
  15. From the layers palette, select head_zero and move it to the mesh_CLASSNAME layer.
  16. Add a SKIN_WRAP modifier to head_zero, using the base character mesh to copy the bone weights. Convert to skin, make sure the head moves correctly, then delete the skin_wrap modifier.
  17. Add a MORPHER modifier to head_zero, use 'Load Multiple Targets...' and then select your morphs_LOW objects.
  18. Test a morph to make sure head_zero behaves as expected. Move the MORPHER layer below the SKIN layer.
  19. Run the TF2 Morph Creator script utility. Under 'Morph Base,' choose head_zero and then click Generate Morph Frames.
  20. Scrub the animation to make sure the morphs work.
  21. Rejoice, because you are done!

Extra: Creating Items with Flexes

  1. The script requires a specific arrangement of modifiers. For the head_zero, it expects from bottom to top - Editable Mesh, Morpher, Skin.
  2. For the object that NEEDS flexes/morphs, it expects from bottom to top - Editable Mesh, Skin Wrap (Vertex, target being head_zero), Skin.
  3. First, set up the morph frames. Do this by selecting 'Morph Base' (head_zero) and hitting Generate Morph Frames.
  4. Second, make sure the object that needs flexes has Skin Wrap targeting the head_zero using vertex (not faces). Scrub the animation and adjust the Skin Wrap parameters until the object deforms as acceptably as it can.
  5. Create a new layer in Max for the morph targets of your object. Name it appropriately. For example, 'beard_MORPHS' or 'facemask_MORPHS.'
  6. Select the object needing morphs with the TF2 Morph Utility as 'Base Mesh.' Select head_zero as 'Morph Base.' Click Create Morph Target.
  7. You should have a series of new objects created in the morphs layer, named the same as the morphs on the character.
  8. Add a Morpher layer to your object and select your newly created morphs as the targets. You can then delete the Skin Wrap modifier.
  9. Using the TF2 Morph Utility again, select only your newly flexed object as the 'Morph Base,' and click Generate Morph Frames.
  10. Go through the animation step-by-step and adjust or fix any problems with the morph targets, then reload them. This can be tedious and take awhile, or be very fast and easy, depending on how well the Skin Wrap/script handled the morph creation. Remember that you'll need to make any adjustments to this BY VERTEX - simply moving the prop around will not work.
  11. Export in FBX format. You do not need to create flexes for LODs other than the highest level.

Source: Video Tutorial by Anatoly Volnov, repeated here so I don't have to watch the video every time I forget I need to make the vs.lua blank.