Thank you very much for all the wonderful suggestions :), they all work but not for what I am trying to achieve, now I have access to my script at home so I can be a bit more specific.
What I am trying to do is change the Level & Offset of Duct Fittings. The problem is when you try to change the level of a Fitting, from Level 0 to Level 1 for example (Level 0 - Elevation = 0, Level 1 Elevation = 4000) it changes the Level but not the Offset. If the Fitting is at Level 0 @ 1000 if you change it to Level 1 it will still be @1000 which means it will physically move by the difference in Levels, in our case 4000mm. The problem with this is that if you have a connected Ductwork system and you try to change the Level of a fitting it will break the system because it will try to offset by 4000mm and you have to reconnect the system. The workaround this is to select the fitting change the Level to 1 in the Properties Palette and before hitting apply remove the difference in levels from the Offset parameter, example: If the fitting is @ 1000 on Level 0, and you want to move it to Level 1 and keep its position in the model without breaking the system you have to select the fitting go the the Properties Palette change its Level to 1 and its Offset to -3000 (in our case) and then hit apply. Image 1 shows a typical scenario of fittings that I want to change.
My script works for single instance please see image 2 below (in a way the script changes the two parameter and then hits apply)
When I add more instances (image 3) it seems that its trying to first change the Level parameters and then the Offset parameters. Illustrated in words is something like - Change the Level of Fitting 1 - hit apply, change the Level of Fitting 2 - hit apply… and then go through the same procedure for Offsets.
I want it to look something like this - Change the Level and Offset of Fitting 1 - hit apply, change the Level and Offset of Fitting 2 - hit apply and so on… to me this looks like a Loop but I am pretty bad at scripts at the present moment and cannot figure out how to do it.