Notifications
Clear all

[Closed] Save Vertices on Bone Information

I was wondering if someone could code me a maxscript or point me in the correct direction. I want to save vertices on bones in a txt file in this format:


	*SKIN_VERTEX_DATA	850  {
		*VERTEX	0 1	{
			*BONE	"Bone03"	1.0000000
		}
		*VERTEX	1 2	{
			*BONE	"Bone03"	1.0000000
			*BONE	"Bone02"	0.0000000
		}

It would be greatly appreciated.

2 Replies

I had a script that did almost exactly this, I edited a little to give that output. You may need to edit it some more since you format was a little ambiguous.


(
	--BOOKMARK SOME FUNCTIONS
	GetVertexWeightCount = skinOps.GetVertexWeightCount
	GetVertexWeight = skinOps.GetVertexWeight
	GetVertexWeightBoneID = skinOps.GetVertexWeightBoneID
	GetBoneName = skinOps.GetBoneName

	--FUNCTION TO EXPORT SKIN WEIGHTS
	fn saveSkin obj =
	(
		--SELECT THIS OBJECT
		objskin = obj.skin
		modPanel.setCurrentObject objskin
		
		--START A STREAM
		createms = "" as stringstream
		
		--GET NUMBER OF VERTS
		numVerts = getNumVerts obj.mesh
		
		format "*SKIN_VERTEX_DATA	%  {
" numVerts to:createms

		--LOOP THROUGH VERTS
		for v = 1 to numVerts do
		(
			--GET THE WEIGHTS
			weights = #()
			_bones = #()

			for b = 1 to GetVertexWeightCount objskin v do
			(
				append weights (weight = GetVertexWeight objskin v b)
				append _bones (_bone = "$'" + (GetBoneName objskin (GetVertexWeightBoneID objskin v b) 1) + "'")
			)
			
			--PRINT THE WEIGHTS
			numBones = _bones.count
			
			format "	*VERTEX	% %	{
" (v-1) numBones to:createms
			
			for n = 1 to numBones do
			(
				format "		*BONE		\"%\"		%
" _bones[n] weights[n] to:createms
			)

			format "	}
" to:createms
		)
		
		format "}
" numVerts to:createms
		
		--CREATE A FILE ON DISK AND SAVE IT
		skinFile = createFile ("$temp\\" + obj.name + ".txt")
		format "%" (createms as string) to:skinFile
		close skinFile
	)
	
	for obj in selection do
	(
		if isProperty obj #skin do saveSkin obj
	)
)

I must thank you deeply, for it is perfect. :bowdown: