BennyE
09-24-2004, 04:29 PM
I have a problem with controlling execution of a script using skinOps.
Im using skinOps to assosiate bones and weights with my mesh, importing bones and weights from a custom fileformat and then applying them to my model. The individual parts of the script works just fine, no problems with the actual code as far as im able to tell, but when i put everything together into a function and run it the code fails.
Ive nailed it down to this section of code:----snip----
skinData = SkinWeightsData()
if skinData.import() != True do throw "Unable to import data"
aryBoneIDs = #()
for num = 1 to skinData.transformCount do append aryBoneIDs num
--remove old bones
iNumBones = skinOps.GetNumberBones skinModifier
for i = 1 to iNumBones do skinOps.RemoveBone skinModifier 1
-- add bones new bones
for i = 1 to skinData.transformCount do skinOps.addbone skinModifier skinData.transformNames[i] 0
...BREAKPOINT...
for i = 1 to skinData.vertexCount do skinOps.ReplaceVertexWeights skinModifier i aryBoneID skinData.vertexWeights[i])
----snip----
If i execute the script manually untill the breakpoint shown above then wait for the gui to update and then execute the last line then everything works fine but as soon as i put it all into a function and execute that function or select the entire section and manually execute then the thing fails with: Runtime error: Exceeded the vertex countSkin:Skin
This is the error you would get should you try to add vertex weights without first adding the bones. From this behavior i can only gather that skinOps methods are run as separate processes and maxscript is not waiting for the completion of one before starting the next.
Because of this i need to add some kind of functionallity in the breakpoint that forces max to stop and wait for the bones to be added before adding the vertices, but i can not find anything like that besides the sleep command. Using that doesnt work either....i guess that does only halt the execution of all commands for a period of time.
Any thoughts on this problem would be appritiated.
Im using skinOps to assosiate bones and weights with my mesh, importing bones and weights from a custom fileformat and then applying them to my model. The individual parts of the script works just fine, no problems with the actual code as far as im able to tell, but when i put everything together into a function and run it the code fails.
Ive nailed it down to this section of code:----snip----
skinData = SkinWeightsData()
if skinData.import() != True do throw "Unable to import data"
aryBoneIDs = #()
for num = 1 to skinData.transformCount do append aryBoneIDs num
--remove old bones
iNumBones = skinOps.GetNumberBones skinModifier
for i = 1 to iNumBones do skinOps.RemoveBone skinModifier 1
-- add bones new bones
for i = 1 to skinData.transformCount do skinOps.addbone skinModifier skinData.transformNames[i] 0
...BREAKPOINT...
for i = 1 to skinData.vertexCount do skinOps.ReplaceVertexWeights skinModifier i aryBoneID skinData.vertexWeights[i])
----snip----
If i execute the script manually untill the breakpoint shown above then wait for the gui to update and then execute the last line then everything works fine but as soon as i put it all into a function and execute that function or select the entire section and manually execute then the thing fails with: Runtime error: Exceeded the vertex countSkin:Skin
This is the error you would get should you try to add vertex weights without first adding the bones. From this behavior i can only gather that skinOps methods are run as separate processes and maxscript is not waiting for the completion of one before starting the next.
Because of this i need to add some kind of functionallity in the breakpoint that forces max to stop and wait for the bones to be added before adding the vertices, but i can not find anything like that besides the sleep command. Using that doesnt work either....i guess that does only halt the execution of all commands for a period of time.
Any thoughts on this problem would be appritiated.
