Part I of this blog series created an FME workspace to make the 3d model of the scorer in STL format ready to send to a slicer before printing. This post will add some extra functionality and publish it up to FME Flow to create a web app that anyone can use to create and download their model.
TLDR: Go to http://imappingfmevm.lbs.co.nz/fmeserver/apps/3D-Score-Board-Creator to test it out for yourself.
The extra functionality added to the workspace, after creating the STL file with an STL writer, is to:
- Create a unique file name for a second copy of the STL file which is saved to FME Flow’s _FME_SHAREDRESOURCE_DATA folder.
- Validate that the email entered by the user is valid.
- If so save the STL file with a FeatureWriter.
- Upload the file to a public folder on DropBox.
- Send an email to the user with both a download link from DropBox and a link to preview the model on https://www.viewstl.com/
Upload to DropBox and send Email
Later on in the workspace, when writing the STL file with the FeatureWriter and when uploading it to DropBox, we need to know it’s exact path. To make the workspace run locally with FME Form and on FME Flow the workspace checks for the existence of the FME_SHAREDRESOURCE_DATA parameter. If this exists then the workspace is running on FME Flow and the directory name can be set to this value. If it doesn’t exist then it is running on on FME Form and the directory attribute can be set to any local directory.
A unique file name for the STL file is generated with a combination of a DateTimeStamper and a RandomNumberGenerator.
The supplied email address is validated with an AttributeValidator checking that the upper case of the email matches the regex
If the email is valid then the STL file is written to the correct directory with a FeatureWriter and then uploaded to my public DropBox folder with a DropboxConnector.
Next an email is generated and sent which contains links to both download the file from DropBox and a way to view it in your browser using https://www.viewstl.com/. With ViewSTL you can even get it printed for you if you don’t have your own 3D printer.
Create an FME Flow App
The first step to make this available to the public is to publish the workspace to FME Flow. It is published to the DataDownload service with the output of the STL writer included in the download. In theory the output of the FeatureWriter should be able to be used here but I couldn’t get that to work so the file is essentially getting written twice, once for the DataDownload and once for the upload to DropBox. I my look into that further that at a later date.
After testing the workspace runs correctly in FME Flow it is a fairly simple exercise to turn it into an FME Flow app. In the FME Flow web UI, go to Server Apps > Build Workspace App.
Select the workspace, choose the Data Download service and how long you want the token to last (so users don’t have to log in to run it) and then customize the page with headers, footers, description etc.
Mine is still a work in progress but you can try it out here.
Be sure to come back to the Locus Blog for the next chapter in this series | FME and 3D Printing, Pt III – Making the scoring pegs and controlling the printer. For any enquires related to FME and 3D printing please contact Locus.