-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor code to use Argparse instead of GetOpt for improved readability + flexibility #43
Open
Iridium-IO
wants to merge
14
commits into
arpruss:master
Choose a base branch
from
IridiumIO:argparse
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Added Moonraker config, and separated connection settings (Moonraker, Serial) to its own tab
GCode can be uploaded via Moonraker (e.g. to Klipper). Currently does not have authentication support.
…tion - Removes manual "help" and "default" console commands and uses argparse generators instead. - config files are now passed directly into the command line by using a '$' prefix, e.g. gcodeplot.py $config.txt - most '--no' prefixes are now reduntant. Some are still retained but I don't really know why they were needed in the first place. Renamed some arguments to be clearer in this regard. - Add type hinting for some parameters Issues: - for some reason the 'cut' mode doesn't generate the exact same ordering of overlapping cuts anymore. All cuts still execute correctly, just the order of shapes being cut is different. To be investigated.
…tantly having to use "Save As" Updated layout of Inkscape config menu. - Added separators and groups to collect similar settings together visually - Now uses type="color" for the extract-color option, allowing visual picking of a color instead of typing in a string.
- Separated svgTree parsing
…ape as uint32 numbers.
…ction angle values. Now accepts "none" at the commandline again - possible that this was causing the variation in the order that shapes were being cut when using 'cut' mode.
Clean up imports
- Cleanup unecessary arguments and enable input parity with old "--no" prefixes - Create enums.py so that argparser_c.py can use it too. - Tidy up __main__ section
- Cleanup unecessary arguments and enable input parity with old "--no" prefixes - Create enums.py so that argparser_c.py can use it too. - Tidy up __main__ section
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Argparse
argparse()
instead ofgetopt()
. This reduces the need to provide separate help/default/variable assignments and makes it easier to manage new parameters. This change is almost entirely feature-equal to the oldgetopt
version, the only real difference being that config files are passed into the script usingpython gcodeplot.py $config.txt
instead ofpython gcodeplot.py --config-file config.txt
.gcodeplotutils/argparse_c
. This mainly has custom extensions to handle features requires for parity with the old system (comments in config files,--no
prefixes, etc)Inkscape
File > Export
in Inkscape. This allows you to keep a degree of separation between the SVG and exported GCode (plus it's fewer clicks when rapidly testing, as you can keep the Export window open in a tab. Saving normally still works as expected.Extract only one color from drawing
now uses the newColor
selector in Inkscape instead of passing RGB values as a stringGeneral
__main__
to reduce nesting and make code easier to read__main__
describing different sectionsNote
This PR also includes the changes from #42 adding Moonraker support. Sorry, I didn't quite know how to separate the changes without deleting all the Moonraker stuff, creating this PR, then re-adding the Moonraker stuff. I don't want to clog up your repo with changes and un-changes, but if you're more happy with this PR (as it's more testable since you don't have Moonraker), I can do the following steps:
Thoughts? I've tested the generated GCode using my own tests (complex overlapped shapes with variable shading/cutting) as well as running the included
mpcnc
andcutter
config files to check that the output gcode is identical. There is some variation in both the new and old files due to non-deterministic choosing of which shapes to draw first (e.g. one time it will drawstar > circle > square
then the next time you run the script it will drawcircle > star > square