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!
Background script in python
Quote from haris.maglic on 1 April 2024, 11:12Hi,
i need to have background script loaded with screen and running in background if it's possible and also how to use some general variables shared between scripts and SIMCNC?
I have tested Pyactions with timer pooling but if i initialize script every time that was loos of time.
Please is there any advice for problem?
Thanks in advance
Hi,
i need to have background script loaded with screen and running in background if it's possible and also how to use some general variables shared between scripts and SIMCNC?
I have tested Pyactions with timer pooling but if i initialize script every time that was loos of time.
Please is there any advice for problem?
Thanks in advance
Quote from CS-Lab Support on 4 April 2024, 07:56Hello,
>> i need to have background script loaded with screen and running in background if it's possible
I don't understand this, try to explain what you mean.
>> and also how to use some general variables shared between scripts and SIMCNC?
Use machine parameters. There are 4000 parameters for a user, where the first 1000 are permanently saved. Machine parameters are present practically everywhere in simCNC (it's something similar to userDRO in Mach3 but better):
- GUI
Most GUI objects can use machine parameters to write entered or read presented values.
- Gcode
Notation: #100 = 40
Reading: G1 X[#100] F200
Assignment: #100 = #101
Subtraction: #99 = #100 - #101
And other arithmetic operations.
- Python
d.setMachineParam( int paramNumber, float value )
d.getMachineParam( int paramNumber )
- Parameter table
The value of individual machine parameters can be read and (some) saved from the parameter table.
>> I have tested Pyactions with timer pooling but if i initialize script every time that was loos of time.
Use a While loop in the macro, this way the macro will never end and the response time will be very short.
Remember to use a small delay in the while loop because it will overload the core.
Hello,
>> i need to have background script loaded with screen and running in background if it's possible
I don't understand this, try to explain what you mean.
>> and also how to use some general variables shared between scripts and SIMCNC?
Use machine parameters. There are 4000 parameters for a user, where the first 1000 are permanently saved. Machine parameters are present practically everywhere in simCNC (it's something similar to userDRO in Mach3 but better):
- GUI
Most GUI objects can use machine parameters to write entered or read presented values.

- Gcode
Notation: #100 = 40
Reading: G1 X[#100] F200
Assignment: #100 = #101
Subtraction: #99 = #100 - #101
And other arithmetic operations.
- Python
d.setMachineParam( int paramNumber, float value )
d.getMachineParam( int paramNumber )
- Parameter table
The value of individual machine parameters can be read and (some) saved from the parameter table.

>> I have tested Pyactions with timer pooling but if i initialize script every time that was loos of time.
Use a While loop in the macro, this way the macro will never end and the response time will be very short.
Remember to use a small delay in the while loop because it will overload the core.
Quote from Koffmatic on 21 September 2024, 15:05Does pyActions mean that configured action should be executed after set event has triggered. So if I set script including only:
print("action started")
to run from machine enabled
shoul it print that when I enable machine? I cannot never get that working so thats why I'm asking. There is no any mentios of use pyactions in any manuals i have read.
Does pyActions mean that configured action should be executed after set event has triggered. So if I set script including only:
print("action started")
to run from machine enabled
shoul it print that when I enable machine? I cannot never get that working so thats why I'm asking. There is no any mentios of use pyactions in any manuals i have read.
Quote from CS-Lab Support on 30 September 2024, 07:00>>> Does pyActions mean that configured action should be executed after set event has triggered.
Exactly.
>>> shoul it print that when I enable machine? I cannot never get that working so thats why I'm asking.
It depends on the type of action used.
Below is an example that displays "action started" after switching simCNC to ENABLED state.
>>> Does pyActions mean that configured action should be executed after set event has triggered.
Exactly.
>>> shoul it print that when I enable machine? I cannot never get that working so thats why I'm asking.
It depends on the type of action used.
Below is an example that displays "action started" after switching simCNC to ENABLED state.
Quote from CS-Lab Support on 1 October 2024, 06:48Forgot to add the picture.
Forgot to add the picture.
Uploaded files:Quote from Koffmatic on 1 October 2024, 13:05Quote from CS-Lab Support on 1 October 2024, 06:48Forgot to add the picture.
That is what I thought it should work. But it never start any scripts I assing to it. What could be reason?
Does script to be on some special folder or is there some bug in my control?
Quote from CS-Lab Support on 1 October 2024, 06:48Forgot to add the picture.
That is what I thought it should work. But it never start any scripts I assing to it. What could be reason?
Does script to be on some special folder or is there some bug in my control?
Quote from Koffmatic on 1 October 2024, 16:24Well. Just found small checkbox before action in pyActions list. When its ticked, scripts start like mentioned.
It should be veeeeery good to see this from software manual. I work typically with siemens S7 and Beckhoff products. Siemens has good manuals for everything. Beckhoff about half of that. Still I am used to look problems kind this from manual.
Well. Just found small checkbox before action in pyActions list. When its ticked, scripts start like mentioned.
It should be veeeeery good to see this from software manual. I work typically with siemens S7 and Beckhoff products. Siemens has good manuals for everything. Beckhoff about half of that. Still I am used to look problems kind this from manual.






















