This causes the cylinder to not render as intended. A common mistake is forgetting to assign a value to a variable. The first two cylinders in the code above are not rendered because they have no height. Below, we call the translate() function so that it sits right on the surface of our enclosure.Cylinder ( r1 = 20, r2 = 5, h = 40, center = true ) We needed to get our PNG down to 6kb to make it render in a reasonable amount of time. When our PNG file was 31kb it took many hours to render and resulted in a huge STL file that was impossible to print. Be sure to keep your PNG files very simple here, otherwise you will run into problems when trying to render. We wanted to use an image of JPEG artifacts for our project, but you could use anything you’d like, or skip this step entirely. The next module creates a texture on the surface of our enclosure from an image file. * This section of the code constructs all of the independent holes and joins them into a uniform object. The second module creates all of the holes that we will place in the enclosure for our electronics components. * Having specified our main enclosure body with rounded edges and an indentation on the bottom, we finally hollow it out. * Having constructed the main box, we can now specify the size of the sphere that we will use to round the edges. Again, difference subtracts the second object from the first, so here, we see a cube and then an offset (translated), smaller cube() */ * Lastly, I am calling difference again here because I wanted to add a small indentation to the bottom of the cube so that it would be more comfortable to hold. We will use a sphere, so that the hard edges of the cube will take on the shape of the sphere. to give the cube rounded edges, we call minkowski, which will trace the shape we specify around the edges. * The first object will be our main cube. We will use this to make our cube hollow. This specifies that we will be subtracting the second object we call from the first. * Next, we call the difference function. * This module constructs the main body of the enclosure. After calling those four modules, all that is left to do is split the enclosure in two and render the halves as separate STL files for printing. The four modules below construct the main body of the enclosure, arrange the holes in the enclosure for our electronic components, add a texture to the enclosure, and assemble all the pieces together. Modules also help break a larger job into more manageable parts and keep the code nice and clean. By assigning variables to parameters, you can vary the size and location of these objects easily. In OpenSCAD, you can quickly build duplicates of small parts into more complex designs using “modules”. OpenSCAD is a great open source solution for CAD and 3D printing projects. We’ve been working in Python to prepare the audio and wanted to generate the enclosure programmatically as well, ideally using open source software. We are currently creating a customized media player to allow people to interact with MP3 artifacts. This is a tutorial on how to use OpenSCAD to design a 3D object via code instead of using a WYSIWYG editor like Tinkercad, Fusion360, etc.
0 Comments
Leave a Reply. |