Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FormerLurker/ArcWelderLib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFormerLurker <hochgebe@gmail.com>2020-12-13 00:49:33 +0300
committerFormerLurker <hochgebe@gmail.com>2020-12-13 00:49:33 +0300
commit893b8eea5e182457e90db9ddbaac8a7fb435a0c7 (patch)
tree421dd5296fcdf57f807c86a2a78ceb5143201fbe /PyArcWelder
parent8cbd08c6c27bb792d28345d24ffc7a7765c35079 (diff)
Prevent arc generation if I and J are both 0 within the current precision. Add default xyz and e precision settings, and enable/disable dynamic gcode precision.
Diffstat (limited to 'PyArcWelder')
-rw-r--r--PyArcWelder/py_arc_welder.h6
-rw-r--r--PyArcWelder/py_arc_welder_extension.cpp76
-rw-r--r--PyArcWelder/py_arc_welder_extension.h11
3 files changed, 89 insertions, 4 deletions
diff --git a/PyArcWelder/py_arc_welder.h b/PyArcWelder/py_arc_welder.h
index 14d5760..ed4e8cc 100644
--- a/PyArcWelder/py_arc_welder.h
+++ b/PyArcWelder/py_arc_welder.h
@@ -46,6 +46,9 @@ public:
double mm_per_arc_segment,
bool g90_g91_influences_extruder,
bool allow_3d_arcs,
+ bool allow_dynamic_precision,
+ unsigned char default_xyz_precision,
+ unsigned char default_e_precision,
int buffer_size,
PyObject* py_progress_callback
): arc_welder(
@@ -59,6 +62,9 @@ public:
mm_per_arc_segment,
g90_g91_influences_extruder,
allow_3d_arcs,
+ allow_dynamic_precision,
+ default_xyz_precision,
+ default_e_precision,
buffer_size
){
guid_ = guid;
diff --git a/PyArcWelder/py_arc_welder_extension.cpp b/PyArcWelder/py_arc_welder_extension.cpp
index 25eb9d9..1e0728b 100644
--- a/PyArcWelder/py_arc_welder_extension.cpp
+++ b/PyArcWelder/py_arc_welder_extension.cpp
@@ -195,7 +195,24 @@ extern "C"
std::string message = "py_gcode_arc_converter.ConvertFile - Beginning Arc Conversion.";
p_py_logger->log(GCODE_CONVERSION, INFO, message);
- py_arc_welder arc_welder_obj(args.guid, args.source_path, args.target_path, p_py_logger, args.resolution_mm, args.path_tolerance_percent, args.max_radius_mm, args.min_arc_segments, args.mm_per_arc_segment, args.g90_g91_influences_extruder, args.allow_3d_arcs, DEFAULT_GCODE_BUFFER_SIZE, py_progress_callback);
+ py_arc_welder arc_welder_obj(
+ args.guid,
+ args.source_path,
+ args.target_path,
+ p_py_logger,
+ args.resolution_mm,
+ args.path_tolerance_percent,
+ args.max_radius_mm,
+ args.min_arc_segments,
+ args.mm_per_arc_segment,
+ args.g90_g91_influences_extruder,
+ args.allow_3d_arcs,
+ args.allow_dynamic_precision,
+ args.default_xyz_precision,
+ args.default_e_precision,
+ DEFAULT_GCODE_BUFFER_SIZE,
+ py_progress_callback
+ );
arc_welder_results results = arc_welder_obj.process();
message = "py_gcode_arc_converter.ConvertFile - Arc Conversion Complete.";
p_py_logger->log(GCODE_CONVERSION, INFO, message);
@@ -271,6 +288,60 @@ static bool ParseArgs(PyObject* py_args, py_gcode_arc_args& args, PyObject** py_
args.resolution_mm = 0.05; // Set to the default if no resolution is provided, or if it is less than 0.
}
+ // extract allow_dynamic_precision
+ PyObject* py_allow_dynamic_precision = PyDict_GetItemString(py_args, "allow_dynamic_precision");
+ if (py_allow_dynamic_precision == NULL)
+ {
+ std::string message = "ParseArgs - Unable to retrieve allow_dynamic_precision from the args.";
+ p_py_logger->log_exception(GCODE_CONVERSION, message);
+ return false;
+ }
+ args.allow_dynamic_precision = PyLong_AsLong(py_allow_dynamic_precision) > 0;
+
+ // extract default_xyz_precision
+ PyObject* py_default_xyz_precision = PyDict_GetItemString(py_args, "default_xyz_precision");
+ if (py_default_xyz_precision == NULL)
+ {
+ std::string message = "ParseArgs - Unable to retrieve the default_xyz_precision parameter from the args.";
+ p_py_logger->log_exception(GCODE_CONVERSION, message);
+ return false;
+ }
+ args.default_xyz_precision = gcode_arc_converter::PyFloatOrInt_AsDouble(py_default_xyz_precision);
+ if (args.default_xyz_precision < 3)
+ {
+ std::string message = "ParseArgs - The default XYZ precision received was less than 3, which could cause problems printing arcs. Setting to 3.";
+ p_py_logger->log(WARNING, GCODE_CONVERSION, message);
+ args.default_xyz_precision = 3;
+ }
+ else if (args.default_xyz_precision > 6)
+ {
+ std::string message = "ParseArgs - The default XYZ precision received was greater than 6, which could can cause checksum errors depending on your firmware. Setting to 6.";
+ p_py_logger->log(WARNING, GCODE_CONVERSION, message);
+ args.default_xyz_precision = 6;
+ }
+
+ // extract default_e_precision
+ PyObject* py_default_e_precision = PyDict_GetItemString(py_args, "default_e_precision");
+ if (py_default_e_precision == NULL)
+ {
+ std::string message = "ParseArgs - Unable to retrieve the default_e_precision parameter from the args.";
+ p_py_logger->log_exception(GCODE_CONVERSION, message);
+ return false;
+ }
+ args.default_e_precision = gcode_arc_converter::PyFloatOrInt_AsDouble(py_default_e_precision);
+ if (args.default_e_precision < 3)
+ {
+ std::string message = "ParseArgs - The default E precision received was less than 3, which could cause extrusion problems. Setting to 3.";
+ p_py_logger->log(WARNING, GCODE_CONVERSION, message);
+ args.default_e_precision = 3;
+ }
+ else if (args.default_e_precision > 6)
+ {
+ std::string message = "ParseArgs - The default E precision received was greater than 6, which could can cause checksum errors depending on your firmware. Setting to 6.";
+ p_py_logger->log(WARNING, GCODE_CONVERSION, message);
+ args.default_e_precision = 6;
+ }
+
// Extract the path tolerance_percent
PyObject* py_path_tolerance_percent = PyDict_GetItemString(py_args, "path_tolerance_percent");
if (py_path_tolerance_percent == NULL)
@@ -327,8 +398,7 @@ static bool ParseArgs(PyObject* py_args, py_gcode_arc_args& args, PyObject** py_
args.min_arc_segments = 0; // Set to the default if no resolution is provided, or if it is less than 0.
}
- // Extract Allow Z Axis Changes
- // allow_3d_arcs
+ // extract allow_3d_arcs
PyObject* py_allow_3d_arcs = PyDict_GetItemString(py_args, "allow_3d_arcs");
if (py_allow_3d_arcs == NULL)
{
diff --git a/PyArcWelder/py_arc_welder_extension.h b/PyArcWelder/py_arc_welder_extension.h
index 46944a1..2c2ecec 100644
--- a/PyArcWelder/py_arc_welder_extension.h
+++ b/PyArcWelder/py_arc_welder_extension.h
@@ -52,7 +52,7 @@ struct py_gcode_arc_args {
min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS;
mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT;
g90_g91_influences_extruder = DEFAULT_G90_G91_INFLUENCES_EXTREUDER;
- allow_3d_arcs = DEFAULT_allow_3d_arcs;
+ allow_3d_arcs = DEFAULT_ALLOW_3D_ARCS;
log_level = 0;
}
py_gcode_arc_args(
@@ -66,6 +66,9 @@ struct py_gcode_arc_args {
double mm_per_arc_segment_,
bool g90_g91_influences_extruder_,
bool allow_3d_arcs_,
+ bool allow_dynamic_precision_,
+ unsigned char default_xyz_precision_,
+ unsigned char default_e_precision_,
int log_level_
) {
guid = guid_;
@@ -77,6 +80,9 @@ struct py_gcode_arc_args {
min_arc_segments = min_arc_segments_;
mm_per_arc_segment = mm_per_arc_segment_;
allow_3d_arcs = allow_3d_arcs_;
+ allow_dynamic_precision = allow_dynamic_precision_;
+ default_xyz_precision = default_xyz_precision_;
+ default_e_precision = default_e_precision_;
g90_g91_influences_extruder = g90_g91_influences_extruder_;
log_level = log_level_;
}
@@ -86,6 +92,9 @@ struct py_gcode_arc_args {
double resolution_mm;
double path_tolerance_percent;
bool allow_3d_arcs;
+ bool allow_dynamic_precision;
+ unsigned char default_xyz_precision;
+ unsigned char default_e_precision;
bool g90_g91_influences_extruder;
double max_radius_mm;
int min_arc_segments;