What's the best way to override the facing.py utility?

More
11 Apr 2024 21:06 #298029 by itsgudenuf
I'm using qtdragon_hd RIP and I'd like to override the facing.py utility found in linuxcnc-dev/lib/python/qtvcp/lib/gcode_utility/ so the utility will only perform climb milling when doing a facing operation.

Of course, I'd like to keep things "upgrade safe" so that's why I'm not just dropping in my on facing.py in the source tree.

Thank!
 

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

More
11 Apr 2024 23:08 #298032 by cmorley
# put/rename the file in YOUR CONFIGFOLDER/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py

import sys
import importlib

from qtvcp.lib.qt_ngcgui.ngcgui import NgcGui
from qtvcp.lib.auto_height.auto_height import Auto_Measure
from qtvcp.core import Path, Action

PATH = Path()
ACTION = Action()

# get reference to original handler file so we can subclass it
sys.path.insert(0, PATH.SCREENDIR)
module = "{}.{}_handler".format(PATH.BASEPATH,PATH.BASEPATH)
mod = importlib.import_module(module, PATH.SCREENDIR)
sys.path.remove(PATH.SCREENDIR)
HandlerClass = mod.HandlerClass

# return our subclassed handler object
def get_handlers(halcomp, widgets, paths):
    return [UserHandlerClass(halcomp, widgets, paths)]

class UserHandlerClass(HandlerClass):
    print('\nCustom subclassed handler for custom facing utility - loaded\n')

    def init_utils(self):
        from qtvcp.lib.gcode_utility.facing import Facing          # <<<< modify this
        self.facing = Facing()
        self.w.layout_facing.addWidget(self.facing)

        from qtvcp.lib.gcode_utility.hole_circle import Hole_Circle
        self.hole_circle = Hole_Circle()
        self.w.layout_hole_circle.addWidget(self.hole_circle)

        try:
            from qtvcp.lib.gcode_utility.hole_enlarge import Hole_Enlarge
            self.hole_enlarge = Hole_Enlarge()
            ACTION.ADD_WIDGET_TO_TAB(self.w.tabWidget_utilities,self.hole_enlarge, 'Hole Enlarge')
        except Exception as e:
            print("Utility hole enlarge unavailable: {}".format(e))

        #LOG.info("Using NGCGUI utility")
        self.ngcgui = NgcGui()
        self.w.layout_ngcgui.addWidget(self.ngcgui)
        self.ngcgui.warp_info_frame(self.w.ngcGuiLeftLayout)

        self.auto_measure = Auto_Measure(self.w)
        self.w.layout_workpiece.addWidget(self.auto_measure)
        self.auto_measure._hal_init()

Try this.
save it here on your system:  CONFIGFOLDER/qtvcp/screens/qtdragon_hd/qtdragon_hd_handler.py
Then change the one line I marked to load your new facing program.

from qtvcp.lib.gcode_utility.facing2 import Facing 

I assume it's basically the same. Make sure it's in the path stated above and change the import line/program to suit the name.

Is your version suitable for integration into linuxcnc?

Chris
The following user(s) said Thank You: Clive S

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

More
12 Apr 2024 00:48 #298039 by itsgudenuf
Thanks Chris.

I'll give this a try as soon as I get back into town.

Yes, I hope my version will be suitable for integration. Once it's adequately tested I'll be sure to share it for integration.
~Brian
The following user(s) said Thank You: cmorley

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

More
19 Apr 2024 13:59 #298617 by itsgudenuf
It took a little of extra time to get things working like I wanted.  I've now got a side to side climb only facing routine, along with an always climb milling path moving inward.

I modified your suggested qtdragon_hd_handler.py to work with other customizations you've suggested in other posts.  I don't like how I hard coded the path to the face.py file but it works for now.

If you think the additional facing routines could be helpful to others, I'll make a PR on Github.

For anyone who might want to try this with an RIP installation, here's what needs to happen:
  • copy the new images to linuxcnc-dev/share/qtvcp/images/gcode_utility/
  • mkdir <CONFIGDIR>/qtvcp/lib/gcode_utility/  and copy face.py and face.ui
  • adjust qtdragon_hd_handler.py as appropriate

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

Moderators: cmorley
Time to create page: 0.417 seconds
Powered by Kunena Forum