In software sometimes we wand to separate out some code that. We may want to use it over and over again, or maybe we want to share it with other people. In JavaCAD we want to use the Factory Pattern meaning we crate a factory with the script, then call it to create objects for us. The simplest case of this is to return a CSG which we call ‘.clone()’.
You can create and share factories just by posting a script in a git repository. By loading up the ArrayList ‘servoMeasurments’ you can pass variables to the factory as parameters. Below you can see the factory itself and how it loads the parameters.
This is a parametric script for generating servos. It takes in a bunch of measurements from your servo and creates the shapes to make a servo.