   MAXscript: Getting vertex weights...
  I use 3ds max 9 and its scripting language to export models into my custom file format. So far, everything is working great but I have one annoying problem: I can't seem to retrieve the weights for the (mesh) vertices.-- write out bone countbone_count = skinops.getnumberbones mesh.modifiers[#skin]vertex_count = mesh.numverts --getnumverticesfor i = 1 to vertex_count do-- loop through all mesh vertices in this mesh(for bone = 1 to bone_count do-- loop through all bones in this mesh(skinops.getvertexweight mesh.modifiers[#skin] i bone))On the skinops.getvertexweight line it tells me that it requires the skin modifier to be selected. Is that really true? If so, I'll have to figure out a way to make the script do this automatically I guess (which I haven't been able to so far) - however, if I manually select the skin modifier and then run the script, it actually complains:-- Runtime error: Exceeded the vertex weight list countSkin:SkinI start to wonder whether this is the correct approach to do this at all. I'm pretty new to MAXscript so please do go easy on me in case this is a redundant or trivial question. I have found cgtalk.com to be the most active MAXscript community but didn't get an answer over there, hopefully there are some people here who can.Thanks ahead of time.[Edited by - d h k on April 29, 2010 7:04:00 AM]
  One single bump for this. I could really use support here. I apologize for the bumping, I waited a long time and I won't do it again.If _anybody_ has _any_ sort of idea or knowledge about the issue or even MAX script in general, I would _really_ appreciate any input. :DSo far, using MAX script to export into a custom model format is absolutely awesome and tons better than using 3ds, obj or x or even fbx but the support is horrible. I tried finding any good places for the scripting language but wasn't able to find any except for this place and cgtalk.com (where nobody answered either).If you need more info/code/whatever, I'll share all that gladly. Just let me know!!   ;  This belongs in graphics since the people there will be much more knowledgeable about MaxScript. Ask the Moderator to move it for you.-ddn   ;  First of all.... dont use max keywords as variable names.bonemeshThe problem you are having is that you are getting total number of bones usedin skin modifier. You want the total number of bones weighting a given vertex.I updated your code to also switch to the modify panel. You should turn on 'Macro Recorder' so you can see all the commands Max is doing underneath.---------------------------msh = $bodyselect mshmax modify mode-- get bone infobones_total_count = skinops.getnumberbones msh.modifiers[#skin]vertex_count = getNumverts msh --getnumvertices -- loop through all mesh vertices in this meshfor i = 1 to vertex_count do(-- loop through all bones affecting this vertexvertex_bone_count = skinOps.GetVertexWeightCount msh.modifiers[#skin] ifor bn = 1 to vertex_bone_count do(weight = skinops.getvertexweight msh.modifiers[#skin] i bn))   ;  Moving to Visual Arts in case those guys have any more insights.   ;  Thanks for the move, Kylotan.WOsborn: Wow! Thanks A TON! It's working, very nice. Super happy to finally have found somebody. :D r++Now I'm figuring out what the best way to get the transformations for each of the total bones. I'm sure I'll get it by reading the manual - if there's an easy way, tho, and you have the time, feel free to put me on the right track.Again, major thank you!   ;  I haven't written a skeleton exporter in a long time so this might be a little off.For each bone you want to write its local position and rotation releative toparent. The ROOT bone will be in world_space. For every CHILD bone you want totake its transform and multiply against the inverse of its parents transform. That will give you its local transform.--------------------------------trans = bn.transformif ( bn.parent != undefined ) then    trans  = trans * (inverse (bn.parent.transform))t = trans.translationpart    // point3r = trans.rotationpart; // quat--------------------------------For animations I think you want to write the transform difference from the last frame.Side Note:You should look at Cal3D. It's an easy to use skeletal animation library. It comes with maya/max exporters. It's opensource so it is good for reference even if you don't end up using it.   