Notifications
Clear all

[Closed] Help with script for copying weights between verts

I have an issue in 3Ds Max 2017 (not Max’s fault, just my need to make a repetative task much quicker).

I have a Mesh with multiple verticies that should be given the same weights (due to being almost overlapping), but Voxel nor Heatmap give them the same weights (like Vert1 Bone1 weight should be the same as Vert2 Bone1).

So I manually select the verticies, copy and paste weights in Weight Table, for each issue. This issue happens a lot all over the character, and will continue to. (Unfortunately in my circumstance, this is the only fix applicable, welding is not).

I tried to use ScriptListener, but that didn’t show all of the code I was hoping it would show. I am also overwhelmed by the complexity that is Python and MaxScript. (I do some minor coding in Microsoft Excel, but that is much simpler than this.)

Could someone make a script, that with the currently selected verticies on the current mesh skin modifier, take the weight of the lowest ID vertex and apply it to all others that are selected? If so, you would be my hero!
Thank you!

2 Replies

This macro below will average weights for every bone on selected vertices
not exactly what you were asking for, but you can modify it easily


fn getWeight2 vertIndex boneIndex =
 (
  local wt=0
  local ii=undefined
  for i=1 to (skinOps.getVertexWeightCount cs vertIndex) do
   (
    if (skinOps.getVertexWeightBoneID cs vertIndex i)==boneIndex do
     (
   ii=i
  )
   )
  if ii!=undefined then wt = skinOps.getVertexWeight cs vertIndex ii
  wt
 )

macroScript averageWeights category:"skIN_toolset"
 (
  selArr = #()
  cs = $.skin
  for i=1 to (skinOps.getNumberVertices cs) do if (skinOps.isvertexSelected cs i==1) do selArr = append selArr i
  if selArr.count > 1 then
   (
    weights = #()
	for k=1 to selArr.count do
	 (
	  weights[k] = #()
	  for i=1 to (skinOps.getNumberBones cs) do weights[k][i] = getweight2 selArr[k] i
	 )
	averWeights = #()
	for i=1 to (skinOps.getNumberBones cs) do
	 (
	  sumW = 0
	  for k=1 to selArr.count do sumW += weights[k][i]
	  averWeights[i] = sumW
	 )
	bonelist = #()
	for j=1 to (skinOps.getNumberBones cs) do bonelist = append bonelist j
	for i=1 to selArr.count do skinops.replaceVertexWeights cs selArr[i] bonelist averWeights
   )
                       else print "wrong section!!!"
 )

Once you copy a vertex weight you can then select multiple others and paste, have you tried that? using the weight tool not the weight table, the weight table in max is rubbish.