AutodeskAILab / Fusion360GalleryDataset

Data, tools, and documentation of the Fusion 360 Gallery Dataset
Other
419 stars 51 forks source link

Add python code to plot sketches with matplotlib #9

Closed JoeLambourne closed 4 years ago

JoeLambourne commented 4 years ago

This PR adds some basic python functionality to plot sketches using matplotlib.

For some documentation on the new code please see tools/sketch2image/README.md

The code provides options allowing the output to be configured. For example the options allow a title and axis to be added to the sketch

ReconstructionExtractor_Z0HexagonCutJoin_3797e54d_Untitled_Sketch2

or for only the sketch to be drawn, something which may be preferable to image processing algorithms

ReconstructionExtractor_Z0HexagonCutJoin_3797e54d_Untitled_Sketch2

The code is broken into two pieces. sketch_plotter.py contains the SketchPlotter class which draws a given sketch. create_sketch_images.py provides a harness which loops over the json files in a folder and creates images for each sketch.

JoeLambourne commented 4 years ago

Ooops. Yes. I see. The default line width wasn't working. I have this fixed now.

I get the following output

Exception processing sketch E:\projects\lambouj\Fusion360GalleryDataset\tools\fusion360gym\data\SingleSketchExtrude_Invalid.json.
'2e239e22-79c4-11ea-b17a-acde48001122'

Completed sketch2image.py

The exception fires because the sketch contains a uuid which doesn't have any corresponding point. SketchPlotter will throw in this case and the exception handling in sketch2image.py or other code using the utility need to catch this and record log the error appropriately.

karldd commented 4 years ago

Excellent. Will merge this in.