In my experience with Alibre Design and AlibreScript - it's often a problem of threading and/or what I can best describe as Alibre Design is built like client/server. Sometimes the client asks for something and the server returns but hasn't finished yet so you don't get the correct answer. This can be seen in the API help somewhere - it is suggested to loop until a helpful answer is given. I don't remember what article. Putting in a sleep will let that thread rest and give the server side time to respond.