Limit the time one step in a loop can take

Limit the time one step in a loop can take

roger.olofsson
Enthusiast Enthusiast
659 Views
2 Replies
Message 1 of 3

Limit the time one step in a loop can take

roger.olofsson
Enthusiast
Enthusiast

Hi,

 

I have a script that I use for batch importing geometry. Sometimes there are "faulty" geometry in the imported file and the loop gets stuck which means that the process isn't done in the morning which casuses problems.

 

Is thera a way to limit the time that a step in a loop is allowed to process? If the import isn't finished in 1 hour continue to the next file in the loop.

 

Thanks,

Roger

0 Likes
660 Views
2 Replies
Replies (2)
Message 2 of 3

blakestone
Collaborator
Collaborator

You could use "TimeStamp" example :

 

(
	local time_start = timeStamp()

	while (true) do (
		
		-- import script
		
		local time_current = timeStamp()
		local time_difference = (time_current - time_start) / 1000		-- seconds
		
		if (time_difference >= 10) then ( 
			exit
		)
	)
	
	print(time_difference)
	
)

The above script will exit the loop after 10 seconds... you could do 3600 for 1 hour

 

if (time_difference >= 3600) then...

 

0 Likes
Message 3 of 3

roger.olofsson
Enthusiast
Enthusiast

Thanks, I will give that a try.

 

Roger

0 Likes