Home Technical Talk

Explode bake methods- a quick script issues

greentooth
Offline / Send Message
WaYWO greentooth
Yo all! Wondering how i can move this components shell in absolute without them to collapse at the center point :(

I saw an artist do it on max and want to do it in maya , and i just copy this phython script :
import math, sys, os
import maya.cmds as cmds
import maya.mel as mel

##Convert selection to verts
sF= (cmds.ls (sl=1))
print (sF)
sV= (cmds.polyListComponentConversion( (cmds.ls (sl=1, flatten=1)), tv=True))
print (sV)
cmds.select (sV)

##make list of selected verts
selectedItems = (cmds.ls (flatten=True, selection=True))
lengthOfList = len(selectedItems)
print ("***Number of items in list " + str(lengthOfList))

##average verts
##print (selectedItems)
xTotal=0
yTotal=0
zTotal=0
for i in xrange(len(selectedItems)):
  ##print ("iteration" + str((i)+1))
  print ("Selected Item in iteration " + str((i)+1) + ": " + str(selectedItems[i]))
  print (cmds.pointPosition (selectedItems[i]))
  xTotal = xTotal + (cmds.pointPosition (selectedItems[i])[0])
  yTotal = yTotal + (cmds.pointPosition (selectedItems[i])[1])
  zTotal = zTotal + (cmds.pointPosition (selectedItems[i])[2])

xNew = (xTotal)/(lengthOfList)
yNew = (yTotal)/(lengthOfList)
zNew = (zTotal)/(lengthOfList)
print ("center of selected items " + str(xNew) + " " + str(yNew) + " " + str(zNew))
It will print the coordinates which i will use to move a similiar shell from my highpoly(the left) using MEL or wathever Phyton (even if i don't know anything about Python...)
Next i'v write a line that gives me unexpected result!!!
move -r -absolute -worldSpaceDistance 1.02103209496 0.0 -2.41864991188;
1413822812-issues1.jpg
Shell i want to move (highpoly)
1413822799-issue-when-execute-that-line.jpg
what i endedup with
Had already search in MEL COMMAND reference site but i just can't figure it out :(
Sign In or Register to comment.