Showing results for 
Search instead for 
Do you mean 
Reply

Pausa or stop a Loop VB NXOpen

Hi guys,

how  is it possible to interrupt (with a button) a loop during execution without lost of the data that the code is going to writing in an external file?

To be more clear: I wrote a code that do some measurement on a 3D geometry varying some parameter with a for loop.

This loop can goes on for days.

The measurements are writed in an external file.

 

Now I need to add a button to interrupt the operation without loss of data.

 

Thanks in advance

 

Luigi

7 REPLIES

Re: Pausa or stop a Loop VB NXOpen

Is this a BlockStyler application? WinForms? Internal app with no UI? External app?
I think we need some more information to help..
Also its always good to state your version of NX..
Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | C# | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: Pausa or stop a Loop VB NXOpen

...sorry I am not an expert, it's a WinForm application (.dll)...

NX9

 

Thank you very much!

 

Luigi

Re: Pausa or stop a Loop VB NXOpen

Hi,

 

I am still not clear to the question, if you want your data to be executed inside for loop, your loop should execute.

 

There are ways you can stop loop using break & conditional statements.

 

Regards

Santosh

Re: Pausa or stop a Loop VB NXOpen

Hi,

I hope to be more clear:

I wrote a code that executes some operations that can continue for days.

So when I click on "RUN" button on the WinForm interface the software starts writing data on an external file and can continue for days.

 

Now I would like to add a new button on the WinForm to stop the execution, to flush the buffer on and to save the file.

 

Thank you

 

Luigi

Re: Pausa or stop a Loop VB NXOpen

for(int i = 0; i < 10; i++)

{ if(i >1)

break;

DoSomeThingWith(i);

}

Re: Pausa or stop a Loop VB NXOpen

As Stefan said, this should be a new question, so that people who are just browsing through the question titles can find the answers.

 

The logic should be something like this:

(1) When the user clicks the "stop" button, you set some global variable to indicate this. So, you might have a line of code like "clicked = True" in the function that handles the button's click event.

(2) Then, every time through your loop (or every tenth time, or every few minutes, or something) you check to see if "clicked = True". If it is, you flush the buffer and close the file.

山田
yamada

Re: Pausa or stop a Loop VB NXOpen

Unfortunately this solution cannot work because the UI freeze and all the button does not work.

I found on internet some solution to release the UI but it seems too complicated.

At the moment I solved with the check if an external file exist.