VBS scripting Lag


I’m working on an auto-rig type of script and I’m having trouble with XSI seeming to lag out for a second while running the script. The script is about 300 lines long and takes a few seconds to run and basically creates a skeleton using a guide I created with a different script.

The problem always seems to happen near the end of the script when the screen goes blank for a second and screws up the bone alignment. Rearranging the order the skeleton is being created in doesn’t seem to make a difference (other than where the problem happens) and running each section on it’s own causes no problems.

Any ideas on how to get around this problem would be appreciated.


it’s hard to tell without seeing what you are doing and the script.
is it top secret or paid/covered work or can you post the offending snippet?


Thanks for the Response.

The code I’m using is a mix of my own and some from some tutorials I bought. I don’t really want to post code I didn’t write, so I’m going to try to narrow down the problem to a smaller section and see if I can clean it up or optimize it a bit. After looking through it a bit, I think I can reduce the large amount of code used in some areas. If I still have problems I will post here again and try to include the problem bits of code.


OK, I’ve rewritten the main part of the bone generation based on some SDK examples which cuts the amount of code needed in half. I would love to get some feedback on if this can be cleaned up even more to be even more efficient.

This will generate the curve the bones will be aligned to:

 SICreateCurve "crvlist", 1, 1
SIAddPointOnCurveAtEnd "crvlist", -5.56400247283325, 15.5115341097636, 4.4254119186418, False, 0

SIAddPointOnCurveAtEnd "crvlist", -7.54199935613224, 15.3638670622132, 2.89084056715819, False, 0

SIAddPointOnCurveAtEnd "crvlist", -9.07458678847619, 14.8604566728363, 3.20805546316486, False, 0

SetValue "crvlist.Name", "R_Arm_Crv"

This will Generate the bones:

 Option Explicit
Dim oRoot, oArmCrv_1, oGeometry, oPos1, oPos2, oPos3, oChain, oBone2, ort, CurSel, bn2Sel, oEff

Dim time_in,LinearNonInterpolated,Time_Out


'**** Start Timer ****

time_in = timer

Function Create2boneChain(Side,Name,view)


set oRoot = application.activeproject.activescene.root

set oArmCrv_1 = oRoot.FindChild(Side & Name & "_Crv")

set oGeometry = oArmCrv_1.activeprimitive.geometry


set oPos1 = oGeometry.Points(0).position

set oPos2 = oGeometry.Points(1).position

set oPos3 = oGeometry.Points(2).position

Logmessage oPos1.x

Logmessage oPos2.x

Logmessage oPos3.x

set oChain = oRoot.Add2DChain( array(oPos1.x,oPos1.y,oPos1.z), array(oPos2.x,oPos2.y,oPos2.z), , view, Side&Name&"_Root" )

Set oBone2 = oChain.AddBone (array(oPos3.x,oPos3.y,oPos3.z), siChainBonePin, Side & Name&"_Bone2")

End Function

Create2boneChain "R_","Arm","0"

'**** End timer ****

time_out = timer

logmessage "elapsed time: " & round(time_out - time_in,3) 

What I found to take a huge amount of time is renaming the bones.

The code I’m using basically finds the root bone (using oRoot.FindChild()), then finds the neighbor (using SelectNeighborObj)and renames it.

Time without renaming the bones:0.078[size=2]
[/size]Time with renaming the bones:0.506

If anyone know a more efficient way to rename the bones I would realy appreciate it.


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.