diff --git a/cmd/goslice/slicer.go b/cmd/goslice/slicer.go index 93e69e6..a396c0c 100644 --- a/cmd/goslice/slicer.go +++ b/cmd/goslice/slicer.go @@ -168,7 +168,11 @@ func (s *GoSlice) Process() error { return err } - err = s.writer.Write(finalGcode, s.options.GoSlice.InputFilePath+".gcode") + if s.options.GoSlice.OutputFilePath == "" { + s.options.GoSlice.OutputFilePath = s.options.GoSlice.InputFilePath + ".gcode" + } + + err = s.writer.Write(finalGcode, s.options.GoSlice.OutputFilePath) fmt.Println("full processing time:", time.Now().Sub(startTime)) return err diff --git a/data/option.go b/data/option.go index 94a23bf..d84ff67 100644 --- a/data/option.go +++ b/data/option.go @@ -272,6 +272,9 @@ type GoSliceOptions struct { // InputFilePath specifies the path to the input stl file. InputFilePath string + + // OutputFilePath specifies the path to the output gcode file. + OutputFilePath string } // Options contains all GoSlice options. @@ -338,6 +341,7 @@ func DefaultOptions() Options { JoinPolygonSnapDistance: 160, FinishPolygonSnapDistance: 1000, InputFilePath: "", + OutputFilePath: "", }, } } @@ -357,6 +361,7 @@ func ParseFlags() Options { flag.Var(&options.GoSlice.MeldDistance, "meld-distance", "The distance which two points have to be within to count them as one point.") flag.Var(&options.GoSlice.JoinPolygonSnapDistance, "join-polygon-snap-distance", "The distance used to check if two open polygons can be snapped together to one bigger polygon. Checked by the start and endpoints of the polygons.") flag.Var(&options.GoSlice.FinishPolygonSnapDistance, "finish-polygon-snap-distance", "The max distance between start end endpoint of a polygon used to check if a open polygon can be closed.") + flag.StringVarP(&options.GoSlice.OutputFilePath, "output", "o", options.GoSlice.OutputFilePath, "File path for the output gcode file. Default is the inout file path with .gcode as file ending.") // print options flag.Var(&options.Print.IntialLayerSpeed, "initial-layer-speed", "The speed only for the first layer in mm per second.")