Skip to content

Commit

Permalink
Merge pull request #18 from IEAWindTask37/blade_only_support
Browse files Browse the repository at this point in the history
Blade only support
  • Loading branch information
akey7 authored Dec 18, 2020
2 parents 95d8377 + 93131ae commit ec59b5e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 17 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ 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 .
```

This module depends on the OpenSCAD package to be installed to render the final `.stl` file. See [http://www.openscad.org/](http://www.openscad.org/)

## 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.
47 changes: 34 additions & 13 deletions windio2cad/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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])
Expand Down

0 comments on commit ec59b5e

Please sign in to comment.