CS-Lab Support Forum for CNC Community
Help to run this brand-new forum and stay with us.
Ask your questions, we are here to help!
run a python script inside a python script. is this possible?
Quote from Frank on 30 March 2023, 20:58Hello,
is it possible in simCNC to call a python script in an python script?
For example:
...d.setSpindleToolNumber(d.getSelectedToolNumber( ))
d.setToolOffsetNumber(d.getSelectedToolNumber( ))
d.runPyAction( probing.py )
...
I got unnown error! The "d.runPyAction( probing.py )" is not working. The external "macro" probing.py is in the same path and is tested. It is working if it is used from the user interface (GUI). What do i wrong?
Which syntax do i have to use? And is there a description of the availabele funtions in the scripts availabele?
Best regards
Frank
Hello,
is it possible in simCNC to call a python script in an python script?
For example:
...
d.setSpindleToolNumber(d.getSelectedToolNumber( ))
d.setToolOffsetNumber(d.getSelectedToolNumber( ))
d.runPyAction( probing.py )
...
I got unnown error! The "d.runPyAction( probing.py )" is not working. The external "macro" probing.py is in the same path and is tested. It is working if it is used from the user interface (GUI). What do i wrong?
Which syntax do i have to use? And is there a description of the availabele funtions in the scripts availabele?
Best regards
Frank
Quote from Frank on 30 March 2023, 22:05Hello again,
i have an other question. I was using Mach before simCNC. When i hve created a new gcode for a milling job, in mach there was a function implemented where i was able to run the new gcode line by line. Afte one line, had to start the procedure again. So i had the coice at any step of the program to step for an other line, or to start a conius run of the program until the end. It was like a debug mode for the gcode. It was very helpful to avoid a crash especialy if you test a new code on a new machine.
Shure, i can place a M1 command between any line i want to check. But this is not a god solution for gcode testing, i guess.
Is there in simCNC a chance to do so? Like a "debug gcode funtionality" ?
Best regards
Frank
Hello again,
i have an other question. I was using Mach before simCNC. When i hve created a new gcode for a milling job, in mach there was a function implemented where i was able to run the new gcode line by line. Afte one line, had to start the procedure again. So i had the coice at any step of the program to step for an other line, or to start a conius run of the program until the end. It was like a debug mode for the gcode. It was very helpful to avoid a crash especialy if you test a new code on a new machine.
Shure, i can place a M1 command between any line i want to check. But this is not a god solution for gcode testing, i guess.
Is there in simCNC a chance to do so? Like a "debug gcode funtionality" ?
Best regards
Frank
Quote from CS-Lab Support on 31 March 2023, 13:12>> I got unnown error! The "d.runPyAction( probing.py )" is not working. The external "macro" probing.py is in the same path and is tested. It is working if it is used from the user interface (GUI). What do i wrong?
>> Which syntax do i have to use? And is there a description of the availabele funtions in the scripts availabele?
Basically, d.runPyAction( ) is used to run a python action, but there is a very interesting trick here.
Create a python action and only configure the python action name and point to the macro.
Then run d.runPy Action( "test" )
When you do that, d.runPyAction( "test" ) will run a python action named "test", and this action will run the "probing.pg" macro.
You're probably wondering why to make such a fuss and make your life harder.
This method (of running a macro from a macro) has one huge advantage, namely, the probing.py macro does not block the macro in which the function d.runPyAction( "test" ) was run.
This is useful when you want macros to run in parallel or independently of each other.There is another much easier way to run a macro from a macro.
This method is blocking, i.e. the main macro is blocked until the secondary macro ends.d.executeGCode(string GCodeCommand)
In this case, only macros named with the letter "M" can be run, e.g. M3 , M4, M20 , M70 etc.
>>> Is there in simCNC a chance to do so? Like a "debug gcode funtionality" ?
Yes.
In the link below you will find a screen with a block by block button added.
>> I got unnown error! The "d.runPyAction( probing.py )" is not working. The external "macro" probing.py is in the same path and is tested. It is working if it is used from the user interface (GUI). What do i wrong?
>> Which syntax do i have to use? And is there a description of the availabele funtions in the scripts availabele?
Basically, d.runPyAction( ) is used to run a python action, but there is a very interesting trick here.
Create a python action and only configure the python action name and point to the macro.
Then run d.runPy Action( "test" )
When you do that, d.runPyAction( "test" ) will run a python action named "test", and this action will run the "probing.pg" macro.
You're probably wondering why to make such a fuss and make your life harder.
This method (of running a macro from a macro) has one huge advantage, namely, the probing.py macro does not block the macro in which the function d.runPyAction( "test" ) was run.
This is useful when you want macros to run in parallel or independently of each other.
There is another much easier way to run a macro from a macro.
This method is blocking, i.e. the main macro is blocked until the secondary macro ends.
d.executeGCode(string GCodeCommand)
In this case, only macros named with the letter "M" can be run, e.g. M3 , M4, M20 , M70 etc.
>>> Is there in simCNC a chance to do so? Like a "debug gcode funtionality" ?
Yes.
In the link below you will find a screen with a block by block button added.
Quote from Frank on 31 March 2023, 15:58Thank you for your quick answer!
espacialy your description of the two different ways to do so and the dependencys. I will use the blocking version, cause i like to create a macro whitch can be started by a normal gcode to change tools belonging to the tooltable (because the tool length offset). During the toolchange the cgode has to be stopped at this point. After the toolchange the probing has to be done befor the normal gcode can proceed.
Inside the probing macro i will stop by using an user question like:answer = msg.askYesNo("Ist das Wekzeug Tool({:d}) eingespannt?\nUND!\nIst der WZL-Taster an dem Messplatz?".format(toolNr), "Ja,Nein" )
if(answer == False):
sys.exit("Abbruch der Messung! Probing failed!")
Just to stop for changing the tool by hand.
Thank you!
For the "block-by-block" theme:
I havent found the block by block button that i need. Where is it paced?
Thanks for all!
Thank you for your quick answer!
espacialy your description of the two different ways to do so and the dependencys. I will use the blocking version, cause i like to create a macro whitch can be started by a normal gcode to change tools belonging to the tooltable (because the tool length offset). During the toolchange the cgode has to be stopped at this point. After the toolchange the probing has to be done befor the normal gcode can proceed.
Inside the probing macro i will stop by using an user question like:
answer = msg.askYesNo("Ist das Wekzeug Tool({:d}) eingespannt?\nUND!\nIst der WZL-Taster an dem Messplatz?".format(toolNr), "Ja,Nein" )
if(answer == False):
sys.exit("Abbruch der Messung! Probing failed!")
Just to stop for changing the tool by hand.
Thank you!
For the "block-by-block" theme:
I havent found the block by block button that i need. Where is it paced?
Thanks for all!
Quote from CS-Lab Support on 3 April 2023, 09:39In the link, I sent you a complete screen. Import it to simCNC using the "Configuration/Set screen" option.
When you do that, you will see this image:
In the link, I sent you a complete screen. Import it to simCNC using the "Configuration/Set screen" option.
When you do that, you will see this image:
Quote from Frank on 4 April 2023, 08:29I haven't selected the right screen and so could not find the described button. It was my foult.
Now i have found it, and it is working like i need it.
Thank you!
Best regards
Frank
I haven't selected the right screen and so could not find the described button. It was my foult.
Now i have found it, and it is working like i need it.
Thank you!
Best regards
Frank