Skip to content

Commit

Permalink
Bt2scad --header option (#52)
Browse files Browse the repository at this point in the history
Adds a --header option to bt2scad, so that .scad headers/parameters can be specified in a file rather than auto-generated.

Also updates the build script and various copyright notices.
  • Loading branch information
aaron-siegel authored Apr 14, 2022
1 parent 90fa872 commit 953c59c
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 25 deletions.
2 changes: 1 addition & 1 deletion LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

puzzlecad is Copyright (c) 2019-2020 Aaron Siegel
puzzlecad is Copyright (c) 2019-2022 Aaron Siegel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 5 additions & 1 deletion scripts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ def bundle_puzzlecad(version, run_tests = True):
shutil.copy2('../src/main/scad/dist/half-hour-example.scad', '../out/dist')
if (os.path.exists('../out/dist/puzzlecad')):
shutil.rmtree('../out/dist/puzzlecad')
shutil.copytree('../src/main/scad/puzzlecad', '../out/dist/puzzlecad')
shutil.copytree(
'../src/main/scad/puzzlecad',
'../out/dist/puzzlecad',
ignore = shutil.ignore_patterns('.*') # Ignore .DS_Store and such cruft
)

print('Creating archive ...')
dist_files = [ os.path.relpath(file, '../out/dist') for file in glob('../out/dist/*') ]
Expand Down
4 changes: 2 additions & 2 deletions scripts/mit-license-header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad

puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.

Expand Down
16 changes: 13 additions & 3 deletions src/main/java/org/puzzlecad/Arguments.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad
puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.
Expand All @@ -36,9 +36,10 @@ public class Arguments {

int[] filterByColor;
String filename;
String header;
boolean stdout;

public Arguments(String[] args) throws Exception {
public Arguments(String[] args) {

for (int i = 0; i < args.length; i++) {

Expand All @@ -61,6 +62,15 @@ public Arguments(String[] args) throws Exception {

stdout = true;

} else if (args[i].equals("--header")) {

if (header == null && i + 1 < args.length) {
header = args[i+1];
i++;
} else {
throw new InvalidCliException();
}

} else {

throw new InvalidCliException();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/puzzlecad/XmpuzzleFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad
puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/puzzlecad/XmpuzzlePiece.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad
puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/org/puzzlecad/XmpuzzleToScad.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad
puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.
Expand All @@ -32,8 +32,7 @@ LICENSE, INDIVIDUAL PUZZLE DESIGNS (INCLUDING VARIOUS DESIGNS THAT

package org.puzzlecad;

import java.io.File;
import java.io.PrintWriter;
import java.io.*;

import static org.puzzlecad.XmpuzzleFile.GRID_TYPE_RECTILINEAR;

Expand Down Expand Up @@ -80,14 +79,25 @@ public void write(PrintWriter out) throws Exception {
out.println("// You can freely edit this file to make changes to the model structure or parameters.");
out.println();

out.println("require_puzzlecad_version(\"2.0\");");
out.println();
if (file.gridType == GRID_TYPE_RECTILINEAR) {
out.println("$burr_scale = " + defaultScale() + ";");
out.println("$auto_layout = true;");
if (arguments.header == null) {
// Generate a header
out.println("require_puzzlecad_version(\"2.0\");");
out.println();
if (file.gridType == GRID_TYPE_RECTILINEAR) {
out.println("$burr_scale = " + defaultScale() + ";");
out.println("$auto_layout = true;");
} else {
out.println("$burr_scale = 27;");
}
} else {
out.println("$burr_scale = 27;");
BufferedReader reader = new BufferedReader(new FileReader(arguments.header));
String line;
while ((line = reader.readLine()) != null) {
out.println(line);
}
reader.close();
}

out.println();

out.println("burr_plate([");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/puzzlecad/XmpuzzleVoxel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad
puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.
Expand Down
4 changes: 2 additions & 2 deletions src/main/scad/puzzlecad.scad
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
Puzzlecad code repository:
https://github.com/aaron-siegel/puzzlecad
puzzlecad is (c) 2019-2020 Aaron Siegel and is distributed under
puzzlecad is (c) 2019-2022 Aaron Siegel and is distributed under
the MIT license. This means you may use or modify puzzlecad for any
purposes, including commercial purposes, provided that you include
the attribution "puzzlecad is (c) 2019-2020 Aaron Siegel" in any
the attribution "puzzlecad is (c) 2019-2022 Aaron Siegel" in any
distributions or derivatives of puzzlecad, along with a copy of
the MIT license.
Expand Down

0 comments on commit 953c59c

Please sign in to comment.