Override set_default_blending

More
08 Jul 2024 12:20 #304660 by rodw
Hi guys, I want to make QTplasmac's custom filter insert a G91 in front of the G64 command but I get an error. This is what I have now to override the method
def set_default_blending_new(self):
    #return(f'G91 G64 P0.1\n\n{data}')
    blend = self.blendTolerance * self.unitMultiplier
    self.gcodeList.append(f'G91 G64 P{blend}')
    self.pathBlend = True
self.set_default_blending = set_default_blending_new  

Can somebody help me straight please?

The actual reason for this is that the files from the nesting program is programmed in G91 but where QTP inserts the  G53 command to move to the top of the Z axis, it  is not permitted in G91 incremental mode. So I want to replace the G91 with G90 and then put the G91 back after you have made that change. Open to other methods. 

Gcode example and filter  attached.I have been able to replace the M07 and M08 with M3/M5 and insert the plasmac feedrate. I am also not sure why the M07 and M08 are still there.



 

File Attachment:

File Name: 10mmcleats.ngc
File Size:1 KB

File Attachment:

File Name: custom_filter.py
File Size:1 KB
Attachments:

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

More
08 Jul 2024 13:12 - 08 Jul 2024 13:19 #304662 by Aciera
As for why the 'M07' and 'M08' are still there:
# for custom parsing before standard parsing
def custom_pre_parse(data):
    if data[:3] == 'M07':
        return(f'M3 $0 \nF#<_hal[plasmac.cut-feed-rate]>\n{data}')
    if data[:3] == 'M08':
        return(f'M5 $0\n\n{data}')        
    if data[:3] == 'G91':
        return(None)    
    return(data)          
self.custom_pre_parse = custom_pre_parse


Note how your code will attach the original string (ie 'M07' and 'M08') stored in the variable 'data' to the return string, so try this:
def custom_pre_parse(data):
    if data[:3] == 'M07':
        return(f'M3 $0 \nF#<_hal[plasmac.cut-feed-rate]>\n')
    if data[:3] == 'M08':
        return(f'M5 $0\n') 
    if data[:3] == 'G91':
        return(None) 
    return(data)   
self.custom_pre_parse = custom_pre_parse
As for the other problem, what is the error you are getting?[/code][/code]
Last edit: 08 Jul 2024 13:19 by Aciera. Reason: Fix forgotten line ' return(data) '
The following user(s) said Thank You: rodw

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

More
08 Jul 2024 13:21 #304663 by rodw
Replied by rodw on topic Override set_default_blending
Thanks, that fixed the M07/M08

This is the error I get when I uncomment the set_default_blending_new
Traceback (most recent call last):
  File "/usr/bin/qtplasmac_gcode", line 1439, in <module>
    app = Filter(sys.argv)
          ^^^^^^^^^^^^^^^^
  File "/usr/bin/qtplasmac_gcode", line 153, in __init__
    self.process_file()
  File "/usr/bin/qtplasmac_gcode", line 244, in process_file
    line = self.parse_code(line)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/qtplasmac_gcode", line 308, in parse_code
    self.set_default_blending()
TypeError: set_default_blending_new() missing 1 required positional argument: 'self'

 

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

More
08 Jul 2024 13:23 #304664 by Aciera
maybe try:
def custom_pre_parse(data):
    if data[:3] == 'M07':
        return(f'M3 $0 \nF#<_hal[plasmac.cut-feed-rate]>\n')
    if data[:3] == 'M08':
        return(f'M5 $0\n') 
    if data[:3] == 'G91':
        return(None) 
    if data[:3] == 'G64':
        return(f'G91\n\n{data}'
    return(data)   
self.custom_pre_parse = custom_pre_parse

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

More
08 Jul 2024 13:30 #304666 by rodw
Replied by rodw on topic Override set_default_blending
Good try but no go It fixed the error but did nothing! 

SO back to the python error.

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

More
08 Jul 2024 13:48 #304667 by Aciera
have you tried not calling 'self' as an argument:
def set_default_blending_new():
    blend = self.blendTolerance * self.unitMultiplier
    self.gcodeList.append(f'G91 G64 P{blend}')
    self.pathBlend = True
self.set_default_blending = set_default_blending_new

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

More
08 Jul 2024 20:17 #304694 by rodw
Replied by rodw on topic Override set_default_blending
Sorry, went past my bed time!

The only way I got it to work was to set incremental  mode with the M03
def custom_pre_parse(data):
    if data[:3] == 'M07':
        return(f'G91  M3 $0 \nF#<_hal[plasmac.cut-feed-rate]>\n')

And a bit more gymnastics  because you can't always assume G90 is active
 

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

More
09 Jul 2024 00:15 #304714 by phillc54
@rodw Is this working OK for you?

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

More
09 Jul 2024 01:38 #304719 by rodw
Replied by rodw on topic Override set_default_blending

@rodw Is this working OK for you?

Phill, 
Thans for asking. Its kind of working but not ideal becasue it issues a G91 on every M03. I really want to be able to redfine this function so it inserts  G91 just once. Any help or guidance is appreciated as this is the first time I have ventured into filters.
def set_default_blending_new(data):
    blend = self.blendTolerance * self.unitMultiplier
    self.gcodeList.append(f'G91 G64 P{blend}')
    self.pathBlend = True
self.set_default_blending = set_default_blending_new

The gcode is being generated by Hypertherm nestmaster so it will be cool to get it supported by qtplasmac out of the box.

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

More
09 Jul 2024 03:59 - 09 Jul 2024 04:00 #304722 by phillc54
I think that all you need in the custom filter is:
def custom_pre_parse(data):
    if data[:3] == 'M07':
        return(f'\nF#<_hal[plasmac.cut-feed-rate]>\nM3 $0')
    if data[:3] == 'M08':
        return(f'M5 $0\n')        
    return(data)          
self.custom_pre_parse = custom_pre_parse

def custom_post_parse(data):
    if data[:3] == 'M30':
        return(f'G90\n{data}')
    return(data)
self.custom_post_parse = custom_post_parse
Last edit: 09 Jul 2024 04:00 by phillc54.

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

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