![]() Otherwise (as shown by the “else” block) it will just create the same size hole as we’ve used before. if our variable “i” equals 1), it uses a slightly larger radius. This checks to see if we’re on the first circle. What’s interesting is the if.else code blocks we added. The scaling change is pretty straight forward. Lets look at some code that solves this problem, and corrects the scaling issue. ![]() If we pick one hole and make it larger (with a corresponding larger post), then it would solve this problem. Since all of the circles are the same size, the part could be oriented in any direction, changing the relative angle of the slot to other parts. This may still be a little tricky for your printer, depending on how well calibrated it is, so if you want to print this you may consider resizing it in your print software before your print it.Īlso, there’s another problem, mainly the orientation of the slot. First, to make this more reasonable, I’m going to scale all the sizes up by 10. Posts along the outside are going to hold this in place, and later on another part will be added to fit through the center slot. Let’s assume this is a spacer between two other parts. Now that’s beginning to look like a part we could possibly use. We’ll also cut out a slot in the center of the whole thing. Now let’s make this a little more useful, and wrap this in a difference block, where the individual cylinders are cut out of a larger cylinder. The variable “pathRadius” is just providing the radius from the center of the group to the center of the individual circles. ![]() Finally, we’re using “num” in the sine and cosine functions to determine how many degrees our current cylinder iteration should be placed at by dividing 360 degrees by the number of cylinders: Second, the translate statement is using sine and cosine to compute the location. How is this different from the linear example from before? First, the for loop is set to go from one to “num”, giving us greater control over how many circles we make. You can try changing the number of circles and the radius by changing the variables “pathRadius” and “num”. Press F5 to compile this, and you should see 8 cylinders like before, this time in a circle. This is going to be very similar, but we’re going to use some of the built-in trig functions to place them in a circular path. After it’s done with the last iteration (“5”) it stops executing that block of code, which means it no longer places cylinders contained in that block. Since “i” is being used to determine the placement on the X-axis, this is causing a cylinder to be placed 1 mm further along on that axis. With each iteration “i” is increasing by one. You should see a string of 5 small cylinders in a row. Start OpenSCAD, and enter the following in the text area on the left: While it is looping, you can access the value it is currently is on. For loops take a given set of values and iterate through each value once. OpenSCAD has one kind of loop, called a “for loop”. Loops allow us to execute a block of code over and over again. This is in part to illustrate some aspects of the language's syntax, and in part to show how to work with a model when one of the built-in modules does not seem to do the job you need it to do.įirst, let’s examine loops, and how to use them when dealing with circular parts. We’re going take a more algorithmic approach to working with them. There are a few different ways of working with curves and circles in OpenSCAD. If you have not read that article yet, and haven’t used OpenSCAD before, you may want to look over that before proceeding. This article will examine this, and look deeper into the OpenSCAD language as a continuation of our other article, “ Using OpenSCAD for 3D Printing”. Although this is pretty straight forward when it comes to modifying parts lengths and linear values using variables, it may not be as clear where to start with circular parts. One of the strengths of OpenSCAD is it’s ability to parametrically handle parts. Solution home Designing with Free Software OpenSCAD tutorials Circular Parts : Using Loops, Modules, and Conditions In OpenSCAD
0 Comments
Leave a Reply. |