Skip to content

Commit

Permalink
closes #137. Convert between 'new line' and '\n' for Slic3r
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethjiang committed Oct 19, 2017
1 parent 1b1f9a6 commit fcf6638
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions octoprint_slicer/static/js/octoprint_slicer.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -32688,6 +32688,13 @@ function OverridesViewModel(parameters, array_keys, enum_keys, item_keys, boolea
return !!m[k]; // Just take a guess if we can't figure it out.
};

// Hacky - Slic3r profiles escape new line to be string '\n'
if (self.slicingViewModel.slicer() == 'slic3r') {
_.forEach(['end_gcode', 'start_gcode'], function (key) {
profile[key] = profile[key].replace(/\\n/g, '\n');
});
}

// Some options are arrays in cura but not Slic3r. Keep track of which.
self.isArray = [];

Expand Down Expand Up @@ -32778,6 +32785,14 @@ function OverridesViewModel(parameters, array_keys, enum_keys, item_keys, boolea
delete result$$1[k];
}
});

// Hacky - Slic3r profiles escape new line to be string '\n'
if (self.slicingViewModel.slicer() == 'slic3r') {
_.forEach(['profile.end_gcode', 'profile.start_gcode'], function (key) {
result$$1[key] = result$$1[key].replace(/\n/g, '\\n');
});
}

return result$$1;
};
}
Expand Down
15 changes: 15 additions & 0 deletions src/profile_overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export function OverridesViewModel(parameters, array_keys, enum_keys, item_keys,
}


// Hacky - Slic3r profiles escape new line to be string '\n'
if (self.slicingViewModel.slicer() == 'slic3r'){
_.forEach(['end_gcode', 'start_gcode'], function(key) {
profile[key] = profile[key].replace(/\\n/g, '\n');
});
}

// Some options are arrays in cura but not Slic3r. Keep track of which.
self.isArray = [];

Expand Down Expand Up @@ -207,6 +214,14 @@ export function OverridesViewModel(parameters, array_keys, enum_keys, item_keys,
delete result[k];
}
});

// Hacky - Slic3r profiles escape new line to be string '\n'
if (self.slicingViewModel.slicer() == 'slic3r'){
_.forEach(['profile.end_gcode', 'profile.start_gcode'], function(key) {
result[key] = result[key].replace(/\n/g, '\\n');
});
}

return result;
};
}
Expand Down

0 comments on commit fcf6638

Please sign in to comment.