Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
XSI-to-Maya cometSaveWeights export (snippet)
Alan Fregtman's SaveCometWeights for XSI --
(snippet edition -- v1.1)
1. Select one or more enveloped meshes and run this from the script editor.
2. You will have the weights saved as "WEIGHTS__objectname.txt" in Comet's SaveWeights format
under the active XSI project directory.
3. In Maya, use Michael Comet's SaveWeights tool (melscript) to import the weights file.
You can find Comet's script in this zip of his tools:
but if you use Maya 2011, you'll need this specific version of Comet's SaveWeights script:
** CometSaveWeights FORMAT spec:
The file looks like this:
worldPosX worldPosY worldPosZ
localPosX localPosY localPosZ
// Comments look like this.
from time import clock
from win32com.client import constants as c
xsi = Application
lm = xsi.LogMessage
start_time = clock()
for obj in list(xsi.Selection):
lm( obj.FullName )
env = obj.Envelopes(0)
deformer = env.Deformers
weights = env.GetWeights2()
points = obj.ActivePrimitive.Geometry.Points
oTrans = obj.Kinematics.Local.Transform
filepath = XSIUtils.BuildPath(xsi.ActiveProject2.Path, "WEIGHTS__%s.txt" % obj.Name)
cometFile = open(filepath, 'w+')
cometFile.write("// [WEIGHTS]\n")
oPBar = XSIUIToolkit.ProgressBar
oPBar.Maximum = points.Count
oPBar.Step = 1
oPBar.CancelEnabled = True
oPBar.Visible = True
more = ""
for i in xrange(0, points.Count):
oPBar.StatusText = "Vertex #%s" % i
if oPBar.CancelPressed:
more += "[COMPONENT]\n%s.vtx[%s]\n" % (obj.Name, i)
oLocalPos = points(i).Position
more += "%s %s %s\n" % (oLocalPos.X, oLocalPos.Y, oLocalPos.Z)
oGlobalPos = XSIMath.MapObjectPositionToWorldSpace(oTrans, oLocalPos)
more += "%s %s %s\n" % (oGlobalPos.X, oGlobalPos.Y, oGlobalPos.Z)
for d in xrange(0, deformer.Count):
# In XSI weights are 0 to 100, but in Maya, weights go from 0 to 1, so...
mayaWeight = ( float(weights(i)[d]) / 100 )
if mayaWeight > 0.0:
more += "%s %s " % (deformer(d).Name, mayaWeight)
more += "\n"
more = ""
oPBar.Visible = False
cometFile.write( "[END-WEIGHTS]\n[JOINTS]\n%s\n[END-JOINTS]\n\n" % "\n".join([item.Name for item in deformer]) )
timeTaken = clock() - start_time
comment = "Exported %s points in %s seconds. (Speed: ~%s points/sec)" % (points.Count, round(timeTaken, 3), round((float(points.Count) / timeTaken), 3))
cometFile.write("// "+comment+"\n")
cometFile.close() # Done! :D
# Look out on for the pretty plugin edition someday, maybe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.