Jump to content

Using IronPython to create a "Timelapse"


Federico Verrastro

Recommended Posts

Hi,

 

I have a question regarding a funtionality of Buttons in text areas and IronPython Scripts.

 

I have a date range filter and I want it to automaticaly update every 2 seconds (like a timelapse). The idea is to view the data as it came in.

 

I tried implementing this code but it only updates once it is done:

 

import time

 

x = DateMin

 

while x < DateMax:

time.sleep(2)

x = x.AddHours(3)

rangeFilter.ValueRange = ValueRange(DateMin,x)

 

Being DateMax and DateMin the low and high of the datefilter. At first I had a problem with the condition but I also tried implementing with a "for i in range(10)" loop and the result is shown only at the end of the loop (it actualy takes 20s to run it).

 

Is there a way for it to update on every step I also tried checking and unchecking the "Execute in transaction" box but to no avail.

 

Kind regards,

 

Federico

Link to comment
Share on other sites

You might have to use a JavaScript to trigger the IronPython script instead of sleep() in the script.

To do this,

1. Wrap your button in text area around a div with an id say 'myBtn'

2. Insert a JavaScript as

setInterval(function () {

$("#myBtn .sf-element ").trigger("click");

}, 20000);

There are certain limitations of using javascripts like above and these scripts must be tested in each version and not something officially supported

Link to comment
Share on other sites

Thank you, it did work!!

 

The only further question i would have is how to make it stop, it keeps runing whatever I do. I'm not literate in JS and i can't find a way of controling it with IronPython.

 

Edit: I've tried adding a property control dropdown input box which id = "OnOff" and tried the following code:

 

var OnOff = $("#OnOff .ComboBoxTextDivContainer div").text()
alert('Drop down >> ' + OnOff)

while (OnOff == "True") {
setInterval(function () {
	$("#myBtn .sf-element  ").trigger("click");
}, 2000);

}

 

 

 

However it doesnt work. I dont really understand why though.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...