Skip to content

Commit

Permalink
Add --output / -o option to specify a specific output file (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
aligator authored Oct 8, 2020
1 parent e201d9e commit 3e1d005
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/goslice/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions data/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -338,6 +341,7 @@ func DefaultOptions() Options {
JoinPolygonSnapDistance: 160,
FinishPolygonSnapDistance: 1000,
InputFilePath: "",
OutputFilePath: "",
},
}
}
Expand All @@ -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.")
Expand Down

0 comments on commit 3e1d005

Please sign in to comment.