Closed tabashir closed 1 year ago
Hi I'll have to see if it's possible to retrieve the list of active plugins. I think it should be.
Do you have any proposals on the UI for this feature in GFF+? E.g. [active_plugins] to add all activated plugins to the filename, or plugin specific e.g. [plugin_arc_welder], [plugin_settings_guide]. JSON encoding of multiple plugins may be more appropriate e.g. {plugins: {arc_welder, settings_guide}}
What other Cura plugins do you use that this feature would be useful for?
Hi, thanks for the reply.
The only plugins that I would think you would want to add to the filename are those that could affect the gcode in some way, so that you would want an easy way of telling if they are on or off. TabAntiWarping and CuraSlowZ may be examples. I would guess that your example of Settings Guide is one that you would want to ignore since it won't affect the gcode that comes out directly.
For my use case, only Arc Welder is needed. I suggested other plugins because I thought it may be easier to iterate through a list of plugins rather than have specific code for just one with the benefit that being generic, you would be less likely to need another change for another plugin in future. If you went with the generic approach, I think, as you suggest, a tag with [pl_
That said, with more thought, it may be further complicated by needing not only to find out if Arc Welder is active, but also if it is enabled on that particular job. There is a tick box in the settings for the job to toggle it on or off. This may be different to what you are referring to as 'active'?
I think it would be simple to check if a plugin is loaded by Cura or not. I know this information is logged when launching Cura.
It's more difficult to check if a loaded plugin modifies the generated Gcode or not.
Not sure how feasible it is to check if Arc Welder itself is enabled or disabled per job.
Can you share your Cura log file with Arc Welder enabled for a job? Generate some gcode with it enabled, then go to Help > Show Configuration Folder, then paste the contents of cura.log
starting from the timestamp log entry for that print job.
Thank you for looking at this Robert. You are right, you can definitely tell from the logs that it is different and in fact it is run as a post-processor on the original gcode.
I've attached 2 files. One is the log with AW ticked on the job, the other with it unticked.
Your comment on checking for the modified code made me think. The point of Arc Welder is to convert curves from lots of small straight lines to longer curves by sending G2 and G3 codes. This means we can check because if you find G2 and G3 then it's very likely that AW will have been run. I've attached a final file.
This is the first 60ish lines from a file processed by AW. As you can see, it puts some comments in the top starting with: ;ARCWELDERPROCESSED
Later in the file you can see that there are G3 Codes (there were G2 ones as well but much later down the file). I've checked the original unmodified gcode file and there are definitely no G3 or G2 lines in there.
Whether the comments in the file is reliable and will always be put in there I cannot say, but it looks fairly safe to say that if you find G2/3 codes in there that for the purposes of what I was hoping, it would work.
Just found some extra info. After posting my last message, I went back into the cura log and noticed it had appended some more to the logs. This was due to me clicking the 'save to disk' option in order to get that gcode in the earlier message. The extra log shows arc welder stats and other things. Not sure if this is helpful really since it likely appears after you need to have calculated the filename (in this case 'test.gcode'). Thought I'd include it just in case.
` 2023-01-19 20:31:23,811 - DEBUG - [MainThread] cura.AutoSave._onTimeout [64]: Autosaving preferences, instances and profiles took 0.18233203887939453 seconds 2023-01-19 20:31:25,331 - DEBUG - [MainThread] LocalFileOutputDevice.LocalFileOutputDevice.requestWrite [133]: Writing to [/home/xxxx/Desktop/test.gcode]... 2023-01-19 20:31:25,357 - DEBUG - [MainThread] ArcWelderPlugin.ArcWelderPlugin._filterGcode [261]: Using temporary file /tmp/tmpn5fvdbss 2023-01-19 20:31:25,361 - DEBUG - [MainThread] ArcWelderPlugin.ArcWelderPlugin._filterGcode [296]: Running ArcWelder with the following options: ['/home/jezm/.local/share/cura/5.2/plugins/ArcWelderPlugin/ArcWelderPlugin/bin/linux/ArcWelder', '-m=9999.000000', '-t=0.050000', '-r=0.050000', '-x=3', '-e=5', '-v=0.050000', '-c=0', '/tmp/tmpn5fvdbss'] 2023-01-19 20:31:25,655 - DEBUG - [MainThread] ArcWelderPlugin.ArcWelderPlugin._filterGcode [310]: 2023-01-19 20:31:25.004 - arc_welder.gcode_conversion - INFO - Processing GCode. 2023-01-19 20:31:25.004 - arc_welder.gcode_conversion - INFO - Arc Welder Arguments Source File Path : /tmp/tmpn5fvdbss Target File Path (overwrite) : /tmp/tmpn5fvdbss Resolution : 0.05mm (+-0.02500mm) Path Tolerance : 5.000% Maximum Arc Radius : 9999mm Min Arc Segments : 0 MM Per Arc Segment : 0.000 Allow 3D Arcs : False Allow Travel Arcs : True Allow Dynamic Precision : False Default XYZ Precision : 3 Default E Precision : 5 Extrusion Rate Variance % : 5.000% G90/G91 Influences Extruder : False Max Gcode Length : Unlimited Log Level : INFO Hide Progress Updates : False Progress Notification Period : 0.50 seconds Progress: 00.0% complete - Estimating remaining time. Progress: 100.0% complete - 0.28583 seconds total. 2023-01-19 20:31:25.290 - arc_welder.gcode_conversion - INFO - +---------------------------------------------+ | Target File Travel Statistics | +---------------------------------------------+ | Min Max Source Target Change| +---------------------------------------------+ | 0.000mm to 0.002mm 1 1 0.0%| | 0.002mm to 0.005mm 0 0 0.0%| | 0.005mm to 0.010mm 0 0 0.0%| | 0.010mm to 0.050mm 2 2 0.0%| | 0.050mm to 0.100mm 36 36 0.0%| | 0.100mm to 0.500mm 735 627 -14.7%| | 0.500mm to 1.000mm 3333 2949 -11.5%| | 1.000mm to 5.000mm 2251 2335 3.7%| | 5.000mm to 10.000mm 354 363 2.5%| | 10.000mm to 20.000mm 81 81 0.0%| | 20.000mm to 50.000mm 6 6 0.0%| | 50.000mm to 100.000mm 0 0 0.0%| | >= 100.000mm 2 2 0.0%| +---------------------------------------------+ |Total distance source:............11562.564mm| |Total distance target:............11562.858mm| | Total count source:...................6801| | Total count target:...................6402| | Total percent change:..................-5.9%| +---------------------------------------------+
2023-01-19 20:31:25.290 - arc_welder.gcode_conversion - INFO - +----------------------------------------------+ | Target File Extrusion Statistics | +----------------------------------------------+ | Min Max Source Target Change| +----------------------------------------------+ | 0.000mm to 0.002mm 0 0 0.0%| | 0.002mm to 0.005mm 0 0 0.0%| | 0.005mm to 0.010mm 1 1 0.0%| | 0.010mm to 0.050mm 43 27 -37.2%| | 0.050mm to 0.100mm 727 160 -78.0%| | 0.100mm to 0.500mm 17279 2955 -82.9%| | 0.500mm to 1.000mm 34026 2604 -92.3%| | 1.000mm to 5.000mm 3424 4449 29.9%| | 5.000mm to 10.000mm 743 1185 59.5%| | 10.000mm to 20.000mm 443 731 65.0%| | 20.000mm to 50.000mm 53 146 175.5%| | 50.000mm to 100.000mm 0 8 INF| | >= 100.000mm 2 116 5700.0%| +----------------------------------------------+ |Total distance source:.............51030.170mm| |Total distance target:.............51037.619mm| | Total count source:...................56741| | Total count target:...................12382| | Total percent change:..................-78.2%| +----------------------------------------------+
2023-01-19 20:31:25.290 - arc_welder.gcode_conversion - INFO - Arc Welder process completed successfully.
`
Hi Jez,
This is the first 60ish lines from a file processed by AW. As you can see, it puts some comments in the top starting with: ;ARCWELDERPROCESSED
Checking the generated .gcode would be a pain. It's really outside the scope of GFF+ so I'm really against doing that.
I made some progress on this request.
Before installing Arc Welder plugin:
After installing Arc Welder plugin:
I'll see if I can check if the Arc Welder print setting is enabled or not. For now I've only figured out if the Arc Welder plugin is installed and loaded or not.
I can see the Arc Welder cura.log
entries when enabling the print setting and saving gcode as you do.
Nice work. Totally understand that you want to keep to GFF+ scope. I was thinking of checking the generated file purely because I thought that it may be created before you pop up the save dialog (and hence calculate the name) but if that isn't the case then can understand why you wouldn't do that.
Looks a bit worrying that code pop even if it has no effect on the outcome. Would that be solved by putting:
arc_welder_plugin=None
on line 93 so that the variable exists (even if it stays empty due to the call in line 95)?
Not very pythonic I knowj (I'm no python expert though), but may cut down on console noise.
Thanks again for looking at this. Hopefully more people than just me will get benefit!
The print setting [arcwelder_enable]
should work for you. E.g.:
[abbr_machine] [base_name] arcwelder_enable [arcwelder_enable]
Note that [arcwelder_enable]
only updates after disabling the Arc Welder print setting, clearing the build plate and re-slicing. I think this is due to GFF+ not properly updating the print settings format on print settings change event, since right now it only really does it after the slicing event. This is a separate issue.
Lmk if that works for you.
That's great, thank you so much.
Did it work for you? Do you have other specific plugins that you want to do similar with?
Works perfectly when calculating the filename to send to OctoPrint. I didn't even have to clear the build plate, just toggling it and re-slicing works fine.
I did have an issue with save and export, when it brought up the dialog box with the save location, the suggested filename was blank. I think that's due to OS rather than your code though. I've noticed other apps with strange behaviour, I think it's when the app is QT based. GTK app saves seem to work fine.
Thanks again, much appreciated. I don't have other plugins needing name changes myself thanks.
I did have an issue with save and export, when it brought up the dialog box with the save location, the suggested filename was blank. I think that's due to OS rather than your code though. I've noticed other apps with strange behaviour, I think it's when the app is QT based. GTK app saves seem to work fine.
Yes that's a documented issue as described in https://github.com/Ultimaker/Cura/issues/12659. I have experienced it as well as many others. It's not due to GFF+.
I'll close the ticket now then.
Thanks so much for this plugin. I've only just discovered it, saves so much time manually editing filenames.
Would be great if it is possible to add a label for certain plugins being enabled. My specific request would be to label whether Arc Welder has been enabled for that print but could be useful if there are other plugins too.