Problems trying to customize safe_height.setRange(...) via qtplasmac_custom.py

More
24 Apr 2024 22:01 #299031 by shasse
Hi all-

I'm trying to enable qtplasmac to allow a safe_height smaller than 0.75 inches. I followed the basic gist of the advice at forum.linuxcnc.org/plasma-laser/51568-in...xcnc?start=10#297618 which suggests something like the following in a file named qtplasmac_custom.py in the config directory:
self.w.arc_voltage_offset.setRange(-9, 9)
with my specific line in the qtplasmac_custom.py file being:
self.w.safe_height.setRange(0.125, int(self.maxHeight))

I have customized a label in the same qtplasmac_custom.py file, so I think that shows that the qtplasmac_custom.py file is being processed via github.com/LinuxCNC/linuxcnc/blob/56e137...smac_handler.py#L365.

However, I see that the self.set_spinbox_parameters() call happens in that same method but later:

github.com/LinuxCNC/linuxcnc/blob/56e137...smac_handler.py#L380

and it is in the the set_spinbox_parameters method where the regular setting of the safe_height setRange happens: self.w.safe_height.setRange(0.75, int(self.maxHeight))

github.com/LinuxCNC/linuxcnc/blob/56e137...mac_handler.py#L3238

I am wondering due to this call sequence if actually is possible to override the safe_height.setRange(), or if I'm doing something wrong.

Thanks!

Scott

Please Log in or Create an account to join the conversation.

More
25 Apr 2024 00:49 #299035 by phillc54
You will need another custom python file that runs later. The file name can be anything you wish and it is named in the ini file as [DISPLAY]USER_COMMAND_FILE = 

linuxcnc.org/docs/devel/html/plasma/qtpl...#_custom_python_code


 
The following user(s) said Thank You: shasse

Please Log in or Create an account to join the conversation.

More
25 Apr 2024 01:15 #299037 by shasse
Thanks for the explanation. I'll try this and report back.

Please Log in or Create an account to join the conversation.

More
28 Apr 2024 03:05 #299228 by shasse
This worked half way. I added a USER_COMMAND_FILE = qtplasmac_custom_post.py with the python code to set the range:

self.w.safe_height.setRange(0.125, int(self.maxHeight))

I can start QtPlasmaC and interactively set and save a Safe Height value as low as 0.125". However, if I save any value less that 0.75", when I reload QtPlasmaC the value is reset to 2" (my maxHeight).

I think this is happening because the load_plasma_parameters method that loads the value from the prefs file into memory (github.com/LinuxCNC/linuxcnc/blob/56e137...py#L2901C16-L2901C27) happens after set_spinbox_parameters which sets the defaults but before the USER_COMMAND_FILE (I'm not yet sure how that file gets invoked with QtPlasmaC to be honest).

This leaves me at a bit of a loss as to how to customize this. I could just write a sed script to change the python code for now, but that seems like a bit of a hack. Anyone have other thoughts as to how this might be achieved?

Thanks!

Scott

Please Log in or Create an account to join the conversation.

More
28 Apr 2024 09:05 #299237 by phillc54
Could you post your user command file and I will try to come up with something tomorrow afternoon. 
The following user(s) said Thank You: shasse

Please Log in or Create an account to join the conversation.

More
28 Apr 2024 12:35 #299246 by shasse
Thanks Phillip! I thought of something to try and hopefully I'll be at the machine later today to try this. If I re-set the safe height from the prefs after changing the range in the USER_COMMAND_FILE then I think it should work fine.

So then the user command file would be:
self.w.safe_height.setRange(0.125, int(self.maxHeight))
self.w.safe_height.setValue(self.PREFS.getpref('Safe Height', round(25.0 * self.unitsPerMm, 0), float, 'PLASMA_PARAMETERS'))

I'll let you know of that works, so no need for you to try and come up with something for now, but thank you!

Scott

Please Log in or Create an account to join the conversation.

More
28 Apr 2024 22:45 - 29 Apr 2024 12:42 #299279 by shasse
I was on the right track with the idea above, but it still did not fully work. Since the self.load_plasma_parameters() call also happened before the self.w.safe_height.setRange(...) call the in-memory prefs data was still respecting the built-in safe_height range that was in effect when it was initially loaded. The solution is to call self.load_plasma_parameters() again after updating the safe_height.setRange.
self.w.safe_height.setRange(0.125, int(self.maxHeight))
self.load_plasma_parameters()
self.w.safe_height.setValue(self.PREFS.getPref('Safe Height', round(25.0 * self.unitsPerMm, 0), float, 'PLASMA_PARAMETERS'))

That worked. I could change, save, and reload Safe Height values below 0.75".
But looking at this now I think I could ditch the explicit self.w.safe_height.setValue(..) call since that is already being called in the self.load_plasma_parameters(). I'll try that next time I'm at the machine, but the good news is I think there is a way to customize the Safe Height using the stock customizations methods.

Thanks for the help Phillip!

Scott
Last edit: 29 Apr 2024 12:42 by shasse.
The following user(s) said Thank You: phillc54

Please Log in or Create an account to join the conversation.

More
30 Apr 2024 19:32 #299416 by shasse
I confirmed that just the following in a USER_COMMAND_FILE works:
self.w.safe_height.setRange(0.125, int(self.maxHeight))
self.load_plasma_parameters()

Thanks!

Scott
The following user(s) said Thank You: phillc54

Please Log in or Create an account to join the conversation.

Moderators: snowgoer540
Time to create page: 0.136 seconds
Powered by Kunena Forum