Proof read docs
This commit is contained in:
@@ -23,7 +23,7 @@ module hingeBodyHalf() {
|
||||
}
|
||||
```
|
||||
|
||||
Oh no! there now a gap between our `pin` and `hingeBodyHalf`
|
||||
Oh no! there's now a gap between our `pin` and `hingeBodyHalf`
|
||||
|
||||
<Image img={pivotGap} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
@@ -56,8 +56,8 @@ Much better
|
||||
|
||||
<Image img={clearancePivot} style={{backgroundSize: 'contain'}} className="pb-8" />
|
||||
|
||||
We still have more work to do on the pin though. We want to re-use the pin to "subtract" its shape from the other of the hinge, basically we can use our current pint to make a hole.
|
||||
Lets make a temporary new module called `pin2` in this new module and we're going to introduce a new function `rotate` to re-orientate the pin
|
||||
We still have more work to do on the pin though. We want to re-use the pin to "subtract" its shape from the other half of the hinge, basically we can use our current pint to make a hole.
|
||||
Lets make a temporary new module called `pin2`. In this new module and we're going to introduce a new function `rotate` to re-orientate the pin
|
||||
|
||||
```cpp
|
||||
module pin2() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import offset1 from '../../static/img/openscad-tutorial/offset1.png';
|
||||
import offset2 from '../../static/img/openscad-tutorial/offset2.png';
|
||||
import offset3 from '../../static/img/openscad-tutorial/offset3.png';
|
||||
|
||||
Next we're going to learn about a hack that every OpenSCAD coder should know, and that's you can create fillets with `offset`.
|
||||
Next we're going to learn about a hack that every OpenSCAD coder should know, and that is you can create fillets with `offset`.
|
||||
Fillets are often ignored in OpenSCAD because they can be difficult to do, but you're not going to ignore them because you're a good engineer.
|
||||
We need to give fillets their due because they play an important role in reducing stress concentrations, have you ever seen an airplane with sharp square windows?? [Exactly](https://www.youtube.com/watch?v=7rXGRPMD-GQ)!
|
||||
|
||||
@@ -46,8 +46,8 @@ offset(-1)offset(1){
|
||||
|
||||
## Triple Offset
|
||||
|
||||
It gets even better, we can double our negative value and apply a third offset to get external fillets as well, to better understand what's happening here let overlay the shapes after each offset.
|
||||
It gets even better, we can double our negative value and apply a third offset to get external fillets as well, to better understand what's happening here let's overlay the shapes after each offset.
|
||||
|
||||
<Image img={offset3} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
In essence we over expand, then under expand before finally expanding back to the original dimensions, but we have gained fillets in the process, it like kneading bread, the more you do it the better the bread . . . not really stick to 3 max.
|
||||
In essence we over expand, then under expand before finally expanding back to the original dimensions, but we have gained fillets in the process, it's like kneading bread, the more you do it the better the bread . . . not really stick to 3 max.
|
||||
|
||||
@@ -64,7 +64,7 @@ module plateHoles() {
|
||||
|
||||
The reason we're using `[0:2]` and not `[0:3]` is because `0` counts so the code still runs 3 times.
|
||||
I've also introduced another function `echo`, this function can be used to display text to the console, we've added it as a temporary measure to help demonstrate that the code in the `for` loop is run multiple times.
|
||||
You should see in the console the following:
|
||||
You should see the the following in the console:
|
||||
|
||||
```cpp
|
||||
ECHO: "increment is currently", 0
|
||||
@@ -75,7 +75,7 @@ ECHO: "increment is currently", 2
|
||||
|
||||
## Repeating Geometry
|
||||
|
||||
Great, `echo` runs three times. Since we know the value of `increment` changes, lets use that to our advantage and change the value `translate` Z-axis like so:
|
||||
Great, `echo` runs three times. Since we know the value of `increment` changes, lets use that to our advantage and change the Z-axis value of `translate` like so:
|
||||
|
||||
```cpp
|
||||
module plateHoles() {
|
||||
@@ -169,7 +169,7 @@ module plateHoles() {
|
||||
|
||||
<Image img={hole6} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
Fantastic! now that we have our holes place, we need to use `difference` to actually cut the holes into the part, but where to do it?? We could use difference in both the mail and female parts but that would require doing the same thing twice. The best place to do it is in `hingeBodyHalf` since this module is common to both sides of the hinge:
|
||||
Fantastic! now that we have our holes placed, we need to use `difference` to actually cut the holes into the part, but where to do it?? We could use `difference` in both the male and female parts but that would require doing the same thing twice. The best place to do it is in `hingeBodyHalf` since this module is common to both sides of the hinge:
|
||||
|
||||
```cpp
|
||||
module hingeBodyHalf() {
|
||||
|
||||
@@ -25,7 +25,7 @@ pin2();
|
||||
|
||||
<Image img={transparentRotate} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
The `%` character before `hingeBodyHalf()` makes it transparent so that we can see `pin2` within it, and one thing becomes obvious with this view is that a `rotate` of `175` is no right, it needs to be `180`! The `%` character is a "debugging" step, which means it's not going to end up in our final code, it's just helpful in the mean time. There are other characters that can be useful, the full list is
|
||||
The `%` character before `hingeBodyHalf()` makes it transparent so that we can see `pin2` within it, and one thing that becomes obvious with this view is that a `rotate` of `175` is no right, it needs to be `180`! The `%` character is a "debugging" step, which means it's not going to end up in our final code, it's just helpful in the mean time. There are other characters that can be useful, the full list is
|
||||
|
||||
```xml
|
||||
* disable
|
||||
@@ -54,7 +54,7 @@ difference() {
|
||||
|
||||
<Image img={difference} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
There we, go a hole! The way conceptualise how `difference` works is to think of it as subtracting the second child from the first. "child" simply means nested with `difference` so in the above example `pin2` is the second child that we are subtracting from `hingeBodyHalf`.
|
||||
There we, go a hole! The way to conceptualise how `difference` works is to think of it as subtracting the second child from the first. "child" simply means nested within `difference` so in the above example `pin2` is the second child that we are subtracting from `hingeBodyHalf`.
|
||||
|
||||
There is one minor annoyance is that the end of the hole looks like it's glitching a little, this can happen in openscad when two surfaces line up.
|
||||
In this case the end of the `hingeBodyHalf` and the start of `pin2`, it only effects the preview and not the 3d STL export, but to make the preview a little nicer in this situations I'll define a variable with a very small value `tiny=0.005;` and add it strategically to resolve this issue, this part is optional but here's where I added it for pin2:
|
||||
|
||||
@@ -70,8 +70,8 @@ pin(120);
|
||||
|
||||
<Image img={multiRotate} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
Earlier I said that the syntax was for modules was `module yourName() { /* your code */ }`, lets revise that to `module yourName(yourArguments) { /* your code that uses arguments */ }`.
|
||||
As you can see we're using the argument `rotateY` within `rotate` so that that we can change `pin`'s ordination each time we use it by as demonstrated by using `0`, `45` and `120`.
|
||||
Earlier I said that the syntax for modules was `module yourName() { /* your code */ }`, lets revise that to `module yourName(yourArguments) { /* your code that uses arguments */ }`.
|
||||
As you can see we're using the argument `rotateY` within `rotate` so that that we can change `pin`'s orientation each time we use it by as demonstrated by using `0`, `45` and `120`.
|
||||
An argument is much like a variable in that we should name it well, the difference is that it's passed to a module and can only be used within the module.
|
||||
Here our code using our new module instead of `pin2`
|
||||
|
||||
@@ -93,7 +93,7 @@ difference() {
|
||||
}
|
||||
```
|
||||
|
||||
And now we can use the pin as both the hole and the shaft, above is the hole, both looks like the following:
|
||||
And now we can use the pin as both the hole and the shaft, above is code for the hole, and both together are below:
|
||||
|
||||
<Image img={bothHalves} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
@@ -122,7 +122,7 @@ The new argument allows us to increase the radius of the pin, here's an exaggera
|
||||
|
||||
<Image img={exaggeratedClearance} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
That's too much clearance just to demonstrate the principle, in reality we'll use the `clearance` variable that we've already defined with a value of `0.2`. we're ready to put the hinge together now, lets make two modules `hingeHalfMale` and `hingeHalfFemale` which will just be assemblies of modules we've already made.
|
||||
That's too much clearance just to demonstrate the principle, in reality we'll use the `clearance` variable that we've already defined with a value of `0.2`. We're ready to put the hinge together now, lets make two modules `hingeHalfMale` and `hingeHalfFemale` which will be assemblies of modules we've already made.
|
||||
|
||||
```cpp
|
||||
// ... previous module definitions above
|
||||
|
||||
@@ -94,5 +94,5 @@ pin();
|
||||
A couple notes about the above.
|
||||
|
||||
- `cylinder` is the 3d version of `circle` when `h` for height is the length that we would need to extrude `circle` by. It can also take one or two radii, here we're using two because it allows us to add a taper to the pin. The reason why we want to add a taper is because we're starting to think about the assemble of this hinge and if we taper the pin it means the other half of the hinge will be locked on.
|
||||
- In order to add the taper we've defined two variables `pinRadius` and `pitTaper` when, the latter is extra we add to the second `cylinder` radius.
|
||||
- The `translate` is there move the `cylinder` up so that it's centred with the hinge pivot and along so that it's protruding out of the hinge pivot.
|
||||
- In order to add the taper we've defined two variables `pinRadius` and `pitTaper`. The latter is extra we add to the second `cylinder` radius.
|
||||
- The `translate` is there move the `cylinder` up so that it's centred with the hinge pivot and move along so that it's protruding out of the hinge pivot.
|
||||
|
||||
@@ -12,7 +12,7 @@ import bigRadius from '../../static/img/openscad-tutorial/big-radius.png';
|
||||
|
||||
## 2D Primitives
|
||||
|
||||
Designing parts in OpenSCAD is a matter of combining shapes and iterating until you get what you want, so with that in mind lets start with this from this perspective focusing just on one half of the hinge, let look at the blue half.
|
||||
Designing parts in OpenSCAD is a matter of combining shapes and iterating until you get what you want, so with that in mind lets start from this perspective focusing on one half of the hinge, let's look at the blue half.
|
||||
|
||||
<Image img={profile} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
@@ -41,7 +41,7 @@ square([15,3]);
|
||||
|
||||
<Image img={translate} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
`translate` is little different to the modules we've see so far is instead of ending with a semicolon `;` it ends with `{ children }` in the case above it has one child, the `circle`. `tranlates` shifts its children around, we're using it to shift it up by `5`. We put `5` in the second position in the square braces is because we want to shift it along the Y axis, if you're ever not sure which axis you need to shift something just try each until you find the one you're after.
|
||||
`translate` is little different to the modules we've see so far is instead of ending with a semicolon `;` it ends with `{ children }` in the case above it has one child, the `circle`. `translate` shifts its children around, we're using it to shift it up by `5`. We put `5` in the second position in the square braces because we want to shift it along the Y axis, if you're ever not sure which axis you need to shift something, just try each until you find the one you're after.
|
||||
|
||||
We also don't want to have the undercut where the circle meets the square, we can fix that with another square so that there's a nice 90 degree transition. Also for reasons we'll get to later, we don't actually want any overlap between these two squares so it will need shift with translate as well. Here's what we're left with:
|
||||
|
||||
|
||||
@@ -121,4 +121,7 @@ By taking extra steps to add fillets to you part, you've made the part stronger
|
||||
You've already tackled clearances for getting parts to fit together or print-in-place.
|
||||
|
||||
|
||||
Well done.
|
||||
|
||||
|
||||
<!-- Now that you up to speed with openscad you might be interested to learn how to host an OpenSCAD project -->
|
||||
|
||||
@@ -13,11 +13,13 @@ In order to maximise our learning we're actually going to tackle 3 things, that
|
||||
|
||||
We're going to learn:
|
||||
|
||||
1. The basics programming and the OpenSCAD syntax
|
||||
1. Some basic programming and the OpenSCAD syntax
|
||||
2. Some best practices so that you can read your own code a couple days after you wrote it
|
||||
3. Get practise designing a real thing with tolerances and all so that you're well equiped to make your next thing
|
||||
|
||||
We're going to achieve that by making this cute print-in-place hinge, print in place means that there will be no assembly step, both parts of the hinge will be printed pre-assembled.
|
||||
<p className="mt-8">
|
||||
We're going to achieve that by making this cute print-in-place hinge, print in place means that there will be no assembly step, both parts of the hinge will be printed pre-assembled.
|
||||
</p>
|
||||
|
||||
<Image img={hinge} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
@@ -29,7 +31,7 @@ If you came from elsewhere, open the OpenSCAD desktop app or go to our [online e
|
||||
|
||||
<Image img={plainCube} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
OpenSCAD has a number of modules available that allow us to make shapes and cube is one of them.
|
||||
OpenSCAD has a number of modules available that allow us to make shapes and `cube` is one of them.
|
||||
Modules take the form `moduleName(moduleParameters);` or `moduleName(moduleParameters){children}`.
|
||||
Using the `cube` as an example, it take the first form where the moduleName is `cube` and it takes one parameter, though that parameter is an array denoted by the square brackets `[]`, which is basically a series of values.
|
||||
|
||||
@@ -41,11 +43,11 @@ That's because the `[10,10,20]` is giving the cube's dimensions in each axis, th
|
||||
|
||||
Before we go any further, now is a good time to mention a couple of principles that you should always keep in mind for OpenSCAD and programming in general
|
||||
|
||||
1. Computers are incredibly stupid, but do exactly what you tell them to do, which means if there's even a small part of code that's incorrect, then OpenSCAD will display errors, it's normal for this to happen often and bears no reflection on your ability to program keep at it! which leads to the next point.
|
||||
1. Computers are incredibly stupid, but do exactly what you tell them to do, which means if there's even a small part of code that's incorrect, then OpenSCAD will display errors, it's normal for this to happen often and bears no reflection on your ability to program, keep at it! which leads to the next point.
|
||||
2. Never get intimidated, if you don't understand a part of the syntax or code try changing the parameters, see what happens. Playing with the code in this manner is one of the best ways to learn.
|
||||
3. The [OpenSCAD](https://www.openscad.org/cheatsheet/) cheatsheet is very useful as a reference. You should always have it open in a tab.
|
||||
4. There are multiple ways to call these modules, i.e. `cube([10,10,10]); cube(size=[10,10,10]); cube([10,10,10], false);` all have the same result, it depends on if you prefer shorthand or not, to avoid confusion, for this tutorial we'll longhand `argumentName=value` in circumstances where we're using more than one argument, and shorthand if it's only one, i.e. `cube([10,10,10]);` (`[10,10,10]` is considered one value because it a single array).
|
||||
4. There are multiple ways to call these modules, i.e. `cube([10,10,10]); cube(size=[10,10,10]); cube([10,10,10], false);` all have the same result, it depends on if you prefer shorthand or not, to avoid confusion, for this tutorial we'll use longhand `argumentName=value` in circumstances where we're using more than one argument, and shorthand if it's only one, i.e. `cube([10,10,10]);` (`[10,10,10]` is considered one value because it a single array).
|
||||
5. Don't worry about units. nominally the units are in the metric millimetre, since that is the standard global engineering unit, but because it exists in virtual space they are effectively unit-less and can be scaled later.
|
||||
6. If you code isn't working, 9 out of 10 times it's because you are missing a semi-colon `;`, all lines apart from ones with curly brace `}` need to end with a semi-colon.
|
||||
6. If your code isn't working, 9 out of 10 times it's because you are missing a semi-colon `;`, Generally speaking most lines apart from ones with a curly brace `}` need to end with a semi-colon.
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ You should now see the OpenSCAD IDE (integrated development environment)
|
||||
|
||||
<Image img={ide} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
Here we should see the default code in the editor on the left-hand-side, the editor is where we design our CAD parts and we'll cover that more soon. You will also see the result will show up on the right-hand-side (along with the console which gives us extra information). You can click and drag inside the viewer to change the perspective, though the image will only update once you let go of the mouse.
|
||||
Here we should see the default code in the editor on the left-hand-side, the editor is where we design our CAD parts and we'll cover that more soon. You will also see the generated shape on the right-hand-side (along with the console which gives us extra information). You can click and drag inside the viewer to change the perspective, though the image will only update once you let go of the mouse.
|
||||
|
||||
You can also move the object with with right-click and drag, and scrolling will zoom in and out.
|
||||
|
||||
@@ -33,8 +33,8 @@ For that we'll need to learn about the OpenSCAD language. For now, try replacing
|
||||
|
||||
<Image img={cube} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
Don't worry if you don't understand the specifics of what happen here, we'll give you the whole run down next in our introductory tutorial, where you'll learn the basics of OpenSCAD by making a hinge.
|
||||
Don't worry if you don't understand the specifics of what happened here, we'll give you the whole run down next in our introductory tutorial, where you'll learn the basics of OpenSCAD by making a hinge.
|
||||
|
||||
<Image img={hinge} className="mb-8 bg-contain rounded-md overflow-hidden" />
|
||||
|
||||
Already familiar with OpenSCAD? no worries, you can skip ahead to learn more about how to host a OpenSCAD project on CadHub
|
||||
<!-- Already familiar with OpenSCAD? no worries, you can skip ahead to learn more about how to host a OpenSCAD project on CadHub -->
|
||||
|
||||
@@ -3,8 +3,8 @@ title: Why OpenSCAD
|
||||
---
|
||||
|
||||
OpenSCAD is a Code-CAD, which means models are made from a code script rather than from a series of clicks in a user interface.
|
||||
If you want an un-bias opinion on if this is a good paradigm you'll have to look elsewhere because CadHub are massive advocates for it.
|
||||
If you want an un-bias opinion on if this is a good paradigm you'll have to look elsewhere because we/CadHub are massive advocates for it.
|
||||
|
||||
A quick run down is that you get all the benifits of git version control. It makes reusing cad logic with a team much easier, and if you think of CAD models as a communication medium between colleagues and machine, what better way of storing it than in an auditable script.
|
||||
A quick run down is that you get all the benifits of git version control. It makes reusing cad logic with a team much easier, and if you think of CAD models as a communication medium between colleagues and machines, what better way of storing it than in an auditable script.
|
||||
|
||||
We're going to learn OpenSCAD now over [the alternatives](/blog/curated-code-cad) because not only is it very mature and stable, it's also easy to pick up. Let's get started!
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
@apply text-2xl font-bold
|
||||
}
|
||||
|
||||
ul li {
|
||||
.markdown ul li {
|
||||
@apply list-disc ml-4
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const webConfig = require('../app/web/tailwind.config.js')
|
||||
module.exports = {
|
||||
...webConfig,
|
||||
purge: ['./src/**/*.html', './src/**/*.js', './src/**/*.ts', './src/**/*.tsx', './blog/**/*.md', './blog/**/*.mdx', './docs/**/*.md', './docs/**/*.mdx'],
|
||||
purge: ['./src/**/*.html', './src/**/*.js', './src/**/*.ts', './src/**/*.tsx', './blog/**/*.md', './blog/**/*.mdx', './docs/**/*.md', './docs/**/*.mdx', './src/**/*.css'],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user