PDA

View Full Version : Controlling execution


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.

Bobo
09-25-2004, 12:13 AM
I have a problem with controlling execution of a script using skinOps.

...

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.


Not sure about this specific case, but in general, re-selecting the node you are working on causes a rebuilding of the complete modifier stack and often solves such problems. Probably even forcing a re-selection of the modifier in the modifier stack would result in rebuilding the bones cache... Just a shot in the dark, don't have the time and data to try with your code snippet...

BennyE
09-27-2004, 08:42 AM
I guess i was a little to stressed the day i posted to really check all options, i was able to solve it by simply placing a refresh() between the lines. Works ok now.

Thanks anyway.

CGTalk Moderation
01-19-2006, 09:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.