Posts Tagged ‘polygon’

Open Source FTW

Posted by on Monday, December 5, 2011 in Uncategorized
OpenSCAD polygon editor (single HTML file) by Daid

OpenSCAD polygon editor (single HTML file) by Daid

As much as I enjoy using OpenSCAD to create 3D models, I do everything I can to build objects out of cylinders, spheres, and cubes.  Making a polygon is… challenging.  Thankfully, there are a number of people on Thingiverse who have sought to make building polygons in OpenSCAD much less painful.1  The latest OpenSCAD polygon tool by Daid is simple, intuitive, and a shining example of why open source projects are awesome.

As soon as I tried out Daid’s program, I knew it was great.  Quickly drafting a complex polygon would now be a breeze.  However, being able to upload and trace a picture of an object would make it infinitely more useful.  Within a few hours, Daid had responded to my feature request2 and within a single day Thingiverse citizen PieterBos had incorporated this feature into his own OpenSCAD polygon program.  Less than a day after that Daid added the ability to upload traceable images to his own original program.  All of this, the sharing of ideas for features, pushing and encouraging one another to be more awesome… this is what open source collaboration is about.

So, when’s the last time a proprietary closed source program developer knocked out a new feature you requested in three days?  Open source FTW!

Error - could not find Thing 14200.
Error - could not find Thing 13348.
  1. Dang, the new awesome Thingiverse search features sure is awesome…  Thanks Marty! []
  2. For the ability to upload an image for tracing []
Tagged with , , , , , , , , , Leave a comment

Two New OpenSCAD Polygon Tools

OpenScad Polygon Generator by PieterBos

OpenScad Polygon Generator by PieterBos

In a recent OpenSCAD tutorial I described the basic process for creating 2D polygons in OpenSCAD.  However, drawing polygons in OpenSCAD can be very problematic.  Unless every triangle is described in the same “winding order,” some of the triangles in the polygon will be “flipped” causing OpenSCAD to freak out, rather than render them properly.  Rather than designing using OpenSCAD polygons, I tend to either (a) design in Inkscape, export to DXF, and extrude the DXF in OpenSCAD or (b) build up the desired polygon out of boxes and circles.

However, these methods just might be a thing of the past.  Just this week two Thingiverse users have each released a new way to easily create OpenSCAD polygons without all the potential pitfalls from manually writing them.

Simarilius created an Inkscape to Openscad Export extension which will allow you to export an Inkscape shape directly as a OpenSCAD code.  This would be a huge shortcut on the first method I suggested above, since you won’t have to deal with an intermediary file format1 and potential translation problems that could occur.

The second OpenSCAD tool is the OpenSCAD Polygon Generator by PieterBos.  This program provides a nice graphical user interface for designing an object.  Once you’re happy with your designs, you can export them directly as OpenSCAD code.  PieterBos even put together a nice video tutorial to go along with his contribution.

YouTube Preview Image

Both of these tools will go a really long way to creating an easier route to developing more complex forms and making OpenSCAD more accessible.  I can’t wait to see what people design using these tools!

Error - could not find Thing 9376.
Error - could not find Thing 9290.
  1. In this case the DXF []
Tagged with , , , , , , One comment

OpenSCAD Basics: 2D Forms

Posted by on Thursday, January 20, 2011 in Uncategorized

Yesterday I gave you some basic information to get started with OpenSCAD1  Today you’re actually going to get to use some of what you learned yesterday.  Admittedly, most of what you’ll be doing is typing things and hitting F5, but don’t kid yourself – that’s progress!

Let’s concentrate on walking before we run.  While the whole point of a 3D modeling program like OpenSCAD is to create 3D forms, learning to make 2D forms will help you get the hang of the OpenSCAD interface and lay the basis for understanding how the language works.  There are three 2D forms that can be created with OpenSCAD, squares, circles, and polygons.

One quick note before we get started.  Each command in OpenSCAD needs to end with a semicolon.  Okay, I think you’re ready to try to make some shapes!  You can follow along at home by copying the text within the quotes and then hitting F5 to get OpenSCAD to draw the shape for you.

  • Circle.
    • Here’s how you create a circle with a radius of 5mm.
      1. “circle(5);”
    • Want a circle with a radius of 6mm?  No problem!
      1. “circle(6);”
    • In either case, it’s good form to actually define the circle by including a reference to the radius itself.  Here’s how you do that:
      1. “circle(r = 5);”
    • That will draw a circle identical to the first example.  Defining the circle in this way helps us quickly understand at a glance what’s being described – and will come in handy a little later.
  • Square.
    • Here’s how you create a square with each side of 5mm.
      1. “square(5);”
    • Want a square with each side at 6mm?  You guessed it!
      1. “square(6);”
    • You can also turn the square into a rectangle by replacing the number with a bracketed pair of numbers.  One number will be the length and the other number the depth.
      1. “square([4,8]);”
    • If you need a rectangle with different dimensions, all you need to do is change those two numbers.  Easy!
  • Polygon.
    • A polygon is basically just a shape that can lie flat in a plane.  They’re made up of a bunch of points and lines connecting those points.  So, it’s only natural that creating a polygon in OpenSCAD requires doing two things – defining a bunch of points and then defining the lines between those points.
    • Points.
      • When we talk about “points” we’re really talking about coordinates on the XY plane.  If you think back to high school geometry you’ll remember coordinates were usually written like this “(2,5)”.  It’s not very different for OpenSCAD, except that each point is written as:
        1. “[2,5]”
      • Before we actually try to draw a square in OpenSCAD, let’s think about how we would describe a square with each side equal to 5mm.  If we’re drawing the square so that one corner is at the “origin” then we already know one of the coordinates – “[0,0]”.  From there we need three more points to help us describe this square.  Going clockwise from the origin, these points would be “[5,0], [5,5], [0,5]”.  Therefore, the full set of all the points needed to describe our square in a clockwise fashion would be “[0,0],[5,0],[5,5],[0,5]”.
      • Thus, in order to define all the points necessary to draw a polygon, we would say:
        1. “[0,0],[5,0],[5,5],[0,5]”
    • Paths.
      • Now anyone who has ever tried to draw by connecting the dots knows that just having a bunch of points doesn’t matter much unless you actually connect those dots in the correct order.  Defining the order, or path, of the points is a lot simpler than you think.  You just specify the rank order of the various points.  OpenSCAD will draw a line from the first point to the second, second to third, et cetera until it gets to the last point – which it will connect to the first point.
      • There’s only one little trick to defining the path – and that is the first number considered is “0” and not “1.”
      • Just as with the points above, we’re going to use brackets to set the paths apart.  If we described the points in order, then we can specify the path to be the exact same order.  Like so:
        1. “[0,1,2,3]”
    • Polygon.
      • The polygon command will look familiar now that you know how to make a circle, square, and rectangle.  It is,
        1. “polygon([points],[paths]);”
      • All we’re doing with this command is telling OpenSCAD what we want it to do (draw a polygon), the points it needs to think about (points), and then the order or path in which it needs to connect those points (path).  As always, we’re going to end that statement with the semicolon.
      • Let’s substitute in the points and paths from above to draw our square:
        1. “polygon( [ [0,0],[5,0],[5,5],[0,5] ] , [ [0,1,2,3] ]);”
        • (Go ahead and drop that into OpenSCAD and hit F5 to see what happens.)
      • There are a few important things to take note of in the above.  First, there is a bracket around all of the points and another bracket around the digits describing the path.  We’re separating those two brackets (the ones for the points and the ones for the path) by a humble comma.
    • Just as with a connect the dots picture, if you have a sufficiently large list of coordinates and a description of the path between those coordinates you can make any flat shape you desire.

Okay, homework time.  Your homework is to try a few of the examples above.  With each one of those examples, change a few numbers, fiddle with it, see if you can make something else.  Nothing bad is going to happen if you get something wrong.  🙂  And, well, my homework for tonight is to learn some more stuff about OpenSCAD so I can write a tutorial for you tomorrow.

  1. Photo of parametric thin profile whistle courtesy of TeamTeamUSA []
Tagged with , , , , , , , , 6 comments

Vertex, polygon, and diameter recommendations for printing small holes

Posted by on Thursday, January 6, 2011 in Uncategorized
Vertices and radii

Vertices and diameter suggestions

A little over a year ago Nick Ames put together this handy graphic demonstrating his recommendations for designing printable objects with small holes.  The reason this is even a concern is that a printer’s hardware takes longer to calculate the print head’s path on objects that are closer to a true circle. 1  If the calculations are taking too long then the extruder may end up depositing a little bit of extra plastic causing “blobbies.”  This is definitely not a big problem and merely requires some extra clean up which is easily accomplished with a drill bit or sanding.

I would offer a few caveats to Nick’s recommendations.  First, the slower you’re printing the less this is an issue.

Second, these recommendations are really only relevant to vertical holes.  If you’ve got a hole running in the XY plane, there are other considerations – like overhang issues.  For small M3 size holes in the XY plane, I use a high-vertex count polygon or even a true circle.  In those instances the holes are so small that overhangs aren’t a big deal.  And since the hole is being sliced on its side, the hardware doesn’t have to perform a lot of tough calculations.

Third, unless there’s a cosmetic reason go ahead and print with the smallest vertex count polygon your design permits.  There probably won’t be a structural difference and you’ll have less clean up post-printing.

A special thanks and kudos to Jordan Mills for finding Nick’s post and graphic for me!

  1. The RepRap wiki has a lot of math explaining what’s going on here. []
Tagged with , , , , , , , , , , , One comment
What can we help you with today?
I want to chat with Sales.
I have a question about an existing order.
I have a technical question about my device.
Existing Orders
For faster service, enter your order number
(found in your confirmation e-mail)