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
Multiple parameters in G-Code Shell Command Extension #233
Labels
✨ feature request
New feature or request
Comments
Try something like this:
|
Using the code you gave me, I was able to achieve the desired behavior. - {% if X is not None %}
+ {% if X is not none %} Current G-Code.
G-code input into the Mainsail Console.
Shell Script Code Changing #!/usr/bin/bash
Message() {
cat <<- EOF
This script is change rotation_distance value.
Usage: sh change_rotation_distance -x 40 -y 39.5 -z 8.4
sh change_rotation_distance -y 40 -z 8
sh change_rotation_distance -h
NG -> sh change_rotation_distance -x -y -z 8.9
sh change_rotation_distance -x -40 -y -40 -z 8.9
EOF
}
isNumeric() {
if expr "$1" : "[0-9]*$" > /dev/null 2>&1 || ( expr "$1" : "[0-9]*\.[0-9]*$" > /dev/null 2>&1 && [ "$1" != "." ] );then
return_value=0
else
return_value=1
fi
return "$return_value"
}
if [ $# -eq 0 ]
then
Message
exit 0
fi
while getopts x:y:z:h OPT
do
isNumeric "$OPTARG"
return_value=$?
if [ "$return_value" -eq 1 ]
then
if [ "$OPT" = 'h' ]
then
Message
exit 0
elif [ "$OPT" != '?' ]
then
echo "-${OPT} argument is not a positive number."
Message
exit 1
fi
fi
case $OPT in
x) x_axis="$OPTARG" ;;
y) y_axis="$OPTARG" ;;
z) z_axis="$OPTARG" ;;
?) Message
exit 1 ;;
esac
done
if [ "${x_axis}" ]
then
sed -E "s/^(rotation_distance:)\s?[0-9]+\.?[0-9]+(.+#\s?[xX])/\1 ${x_axis}\2/" -i $HOME/klipper_config/printer.cfg
fi
if [ "${y_axis}" ]
then
sed -E "s/^(rotation_distance:)\s?[0-9]+\.?[0-9]+(.+#\s?[yY])/\1 ${y_axis}\2/" -i $HOME/klipper_config/printer.cfg
fi
if [ "${z_axis}" ]
then
sed -E "s/^(rotation_distance:)\s?[0-9]+\.?[0-9]+(.+#\s?[zZ])/\1 ${z_axis}\2/" -i $HOME/klipper_config/printer.cfg
fi Changes to [stepper_x]
- rotation_distance: 32.14
+ rotation_distance: 32.14 # x_axis
[stepper_y]
- rotation_distance: 32.07
+ rotation_distance: 32.07 # y_axis
[stepper_z]
- rotation_distance: 8.09
+ rotation_distance: 8.09 # z_axis Thank you very much for your advice. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe
Not related to a problem.
Describe the solution you'd like
The G-Code Shell Command Extension is a great extension.
I would like to be able to use this extension to change the
rotation_distance
setting from the console.To do this, I have created a script that takes a new
rotation_distance
value as an argument and replaces therotation_distance
value inprinter.cfg
.The usage of this script is:
sh change_rotation_distance.sh -x 40.2 -y 40.4 -z 8.4
With this script, I want to be able to change the setting by typing
RUN_SHELL_COMMAND CMD=change_rotation_distance PARAMS=-x 40.5 -y 40.6 -z 8.7
at the Mainsail console. Therefore, we request the ability to specify multiple parameters.Translated with www.DeepL.com/Translator (free version)
Describe alternatives you've considered
Access the Raspberry Pi via SSH and run
sh change_rotation_distance.sh -x 40.2 -y 40.4 -z 8.4
.However, if the work can be completed in the Mainsail console, the work will be easier than accessing via SSH, so we are making the above suggestion.
Translated with www.DeepL.com/Translator (free version)
Additional information
None.
The text was updated successfully, but these errors were encountered: