diff --git a/README.md b/README.md index b00e7e5..899a5e5 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,11 @@ Read below to learn more about rendering these `.yaml` files into `.stl` files. ## Installation -Clone the repository and change into the repository's directory: +This instllation guide assumes you are using `conda` for management of virtual environments. Clone the repository and change into the repository's directory: -``` +``` +conda create -n windio2cad python=3.8 +conda activate windio2cad pip install -e . ``` @@ -24,8 +26,14 @@ This module depends on the OpenSCAD package to be installed to render the final ## Usage -On a macOS system with OpenSCAD installed in its default location, use the following command to create an `.stl` file for a turbine atop a semisubmersible foundation: +Use the following command to create an `.stl` file for a turbine atop a semisubmersible foundation: ``` -python -m windio2cad --input nrel5mw-spar_oc3.yaml --output turbine.stl --openscad /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD +python -m windio2cad --input nrel5mw-semi_oc4.yaml --output turbine.stl --openscad [PATH TO OPENSCAD] ``` + +Replace `[PATH TO OPENSCAD]` with the path to OpenSCAD on your operating system. + +### Rendering just the blade + +In some applications, only a rendering of the blade is needed. In those cases, simply add the `--blade` option to the command line to render just the blade. diff --git a/windio2cad/__main__.py b/windio2cad/__main__.py index 81cf997..dd2bde4 100644 --- a/windio2cad/__main__.py +++ b/windio2cad/__main__.py @@ -551,7 +551,18 @@ def member( required=True, ) parser.add_argument("--openscad", help="Path to OpenSCAD executable", required=True) - parser.add_argument("--downsample", default=1, type=int, help="Defaults to 1, meaning every cross section is rendered.") + parser.add_argument("--downsample", + default=1, + type=int, + help="Defaults to 1, meaning every cross section is rendered." + ) + parser.add_argument( + "--blade", + default=None, + nargs="?", + const="blade" + ) + args = parser.parse_args() intermediate_openscad = "intermediate.scad" @@ -561,20 +572,30 @@ def member( print(f"Blade downsampling: {args.downsample}") print(f"Intermediate OpenSCAD: {intermediate_openscad}") print(f"Path to OpenSCAD: {args.openscad}") + if args.blade == "blade": + print("Rendering blade only...") + else: + print("Rendering everything...") print("Parsing .yaml ...") - blade = Blade(args.input) - blade_object = blade.blade_hull(downsample_z=args.downsample) - fp = FloatingPlatform(args.input) - tower = Tower(args.input) - rna = RNA(args.input) - - with open(intermediate_openscad, "w") as f: - f.write("$fn = 25;\n") - big_union = solid.union()( - [fp.members_union(), tower.tower_union(), rna.rna_union(blade_object)] - ) - f.write(solid.scad_render(big_union)) + if args.blade == "blade": + blade = Blade(args.input) + blade_object = blade.blade_hull(downsample_z=args.downsample) + with open(intermediate_openscad, "w") as f: + f.write("$fn = 25;\n") + f.write(solid.scad_render(blade_object)) + else: + blade = Blade(args.input) + blade_object = blade.blade_hull(downsample_z=args.downsample) + fp = FloatingPlatform(args.input) + tower = Tower(args.input) + rna = RNA(args.input) + with open(intermediate_openscad, "w") as f: + f.write("$fn = 25;\n") + big_union = solid.union()( + [fp.members_union(), tower.tower_union(), rna.rna_union(blade_object)] + ) + f.write(solid.scad_render(big_union)) print("Creating .stl ...") subprocess.run([args.openscad, "-o", args.output, intermediate_openscad])