Add Intuitiveness To OpenSCAD With Encoders

The first time I saw 3D modeling and 3D printing used practically was at a hack day event. We printed simple plastic struts to hold a couple of spring-loaded wires apart. Nothing revolutionary as far as parts go but it was the moment I realized the value of a printer.

Since then, I have used OpenSCAD because that is what I saw the first time but the intuitiveness of other programs led me to develop the OpenVectorKB which allowed the ubiquitous vectors in OpenSCAD to be changed at will while keeping the parametric qualities of the program, and even leveraging them.

All three values in a vector, X, Y, and Z, are modified by twisting encoder knobs. The device acts as a keyboard to

  1. select the relevant value
  2. replace it with an updated value
  3. refresh the display
  4. move the cursor back to the starting point

There is no software to install and it runs off a Teensy-LC so reprogramming it for other programs is possible in any program where rotary encoders may be useful. Additional modes include a mouse, arrow keys, Audacity editing controls, and VLC time searching.

Here’s an article in favor of OpenSCAD and here’s one against it. This article does a good job of explaining OpenSCAD.

[Editor’s note: This is a Hackaday writer’s hack, hence the “I” in place of the usual “we”. We all love custom peripherals though, and a good number of us love OpenSCAD, so you could probably read it either way, but we don’t want to take credit for [Brian]’s work.]

44 thoughts on “Add Intuitiveness To OpenSCAD With Encoders

      1. He’s just using the Teensy to emulate a keyboard for all of these and sending keystrokes to control the program using it’s normal bindings. The Teensy can emulate a keyboard, mouse, usb-midi, or usb-serial device pretty much out of the box.

    1. The links in the latest blog update to the project all seem to work. The links in all prior blog entries are dead and were probably downlevel data anyway. What doesn’t seem to be available is any BOM, and anything other than the images of the board and schematic. The part that’s got me stumped is described only as ‘an LED strip mounted with two screws’, and any description of how it’s connected to the teensy. Maybe there are pin descriptions in the code; I haven’t looked yet.

  1. The value of OpenSCAD for making quick parts is really high.
    The shift linkage bushings in my car failed this last week. They were not available separately so it would have cost me $180 for a new linkage. I had the new bushings modeled in OpenSCAD in about 5 minutes, printed them in TPU in 20, and had them installed in another 5.

  2. Awesome.

    I’m amazed that engineering design suites haven’t been made into games; they’re getting awfully intuitive. Sure would be cool if you could print out the model that solved a level, and see its use as an actual physical part.

      1. Yeah, you’d have to design something from the ground-up to optimize for user-friendly controls over complexity and overall capabilities. But what DON’T we have a good open-source library for at this point? Bullet is pretty easy to pick up and runs a mean realtime physics simulation.

  3. Next challenge, STEP file export from openSCAD.

    Who’s up for it? I’m unfortunately not a programming type of guy.

    (You can use freeCAD as an openSCAD wrapper of sorts to import SCAD files then export as STEP, but it doesn’t always work…)

    1. STEP can describe polygons but what you really want is Solids. Hence no STEP export in openSCAD yet.
      FreeCAD can import “some” OpenSCAD – same issue. If its polys then you can’t make Solids. Open CG issue for may years. generally regarded as really really really hard.

      1. Yeah, I use Rhino 3D mainly, so I’m used to solids, been a while since I pushed polygons around (I used to use 3DSMax a LOT).

        So openSCAD can model in polys and solids?
        I thought it was mostly a solid based software using mostly boolean for modelling?
        I’ve only poked it a little so far, should give it a go, I like the idea of parametric modelling.

      2. STEP is primarily a BREP model description and is based on a surfacing and topology description. I think OpenSCAD is a Boolean modeler which could produce a BREP. Even BREP modelers use facet models to display results on the screen.

        I dimly recall that STEP also offers CSG support, but using that to import requires a modeler that supports CSG.

  4. Latest OpenSCAD has a customiser where you can define a parameter to use (say) a slider. So can act like Customiser on Thinigverse. Works well.
    A nice thing to do with this would be to auto-hook the encoder/keyboard emulater up to these defined UI parameters.
    Then get it included in the OpenSCAD builds.

  5. All of the sources in the linked blog post are dead. I was very interested in this keyboard since I tend to use OpenSCAD a lot, but the fact that the project is not that well documented and somewhat neglected by its author is putting me off.

  6. Let me troll this thread to remind everyone that OpenSCAD is ridiculously time consuming for solid modelling because it is based on an outdated concept of CAD that became obsolete several decades ago. Constraint-based modelling is the right way and there are good open implementations of that. Someone mentioned FreeCAD but it is quite buggy, Solvespace is a very decent alternative if you want to produce dynamic designs in a matter of minutes.

    1. And we are all going to go find out what “Constraing-based modelling” is just because an internet commentor said so? If you wanted to actually convince us of something you might at least include a sentence or two of explanation!

    2. I found the exact opposite of your point of view. I gave up on the constraint-based SolveSpace in despair and went to OpenSCAD for a few different reasons. Firstly, SolveSpace was having a lot of trouble rendering a >100 tooth plain spur gear that I had imported from a DXF. When it came to extruding it, it took a considerable amount of time (minutes) to do it.
      But by far the worst thing about SolveSpace was the overly punitive error messages. Make a mistake (very easy for a new user) and you get a error dialog box with five or more lines of SolveSpace-speak telling you what you have done wrong. If you are lucky you will only get a dialog with a three-line error message (usually something about not being in-plane). The SolveSpace workplane marker lines are hard to see at the best of times and it is easy to do things on the wrong workplane).

      Sometimes the SolveSpace screen turns to a red background, totally unhelpful except to tell you you’ve *ed up – somewhere. However when you try and find out some help for what it is, the error message (or keyword phrase parts thereof) are not searchable in the help or documentation.
      After all that you then have to OK the dialog to clear it instead of the error being non-modal in for instance a status bar.

      I also tried loading the same DXF in FreeCAD. It loaded fine but when I tried extruding, it froze completely. Repeated the import and extrude a few times, same result. Scratch that.

      OpenSCAD loaded the DXF without any problem at all and I was extruding it and performing other operations in just minutes. Funnily enough I find OpenSCAD with its scripting approach more forgiving than the other two.

      1. I normally fix the red screen by pressing “control z” and I haven’t experienced the levels of frustration you describe. It is worse than Solidworks or Inventor and perhaps there are things that could be improved but I still find it an excellent tool. I was overexcited about OpenSCAD when I first read about it from the Reprap community and I appreciate that it is a well written piece of software but it is still based on an outdated concept and it takes ages to design pretty basic things that a decent modelling software would allow you to do in a couple of minutes. I wrote an OpenSCAD model to make a book shelf and find out how much wood I needed and simple as the geometry was, it took me four fucking hours to complete.

    3. +1 Constraints are the way to go. Long time pro in AutoCAD and Inventor. If you’re looking for free and good, Onshape works pretty well. It also has a much better & modern UI, not the early 90s look of OpensCAD -had OC been available when I started drafting, I would have stayed with a pencil, paper, straightedge and a compass Fortunately, at the time, AutoCAD R12 wasn’t too expensive. OpenSCAD makes me want to find old Turtle System bit drawing charts to create something. You guys remember those huge paper tablets that would help you convert a drawing to machine language?

      1. Or go with fusion 360 which is free to makers and businesses making less than 100k a year. Autodesk sure does understand vendor lock-in, thankfully inventor is a very comprehensive product and quite interesting once you look under the hood at the customization and scripting options once you are ready to start paying for your cad package.

        1. Yes, it’s incredibly easy to get free (educational) 3 year licenses for AutoCAD 2018, Revit 2018 and Inventor 2018. I primarily use Inventor when a customer wants to see their parts in operation as well as quick expanded views. Fusion 360 is great too but used mostly for rapid prototyping on the 3d printers. Add in MeshMixer and you’ve got a nice and free suite to work from.

    4. OpenSCAD takes the useful part of constraints based modeling, without the maddening need to define everything as a constraint.
      If you want something you can change and have everything else change with it, you just model that thing as a variable and pass it around. Of course this requires a little discipline in coding and some analytical thinking to ensure you are accounting for everything, but what good code doesn’t.
      It fits nicely at the intersection of programming and solid modeling, which is my space so I love it.

      1. I don’t think it borrows anything from constraint based modeling. It just takes a lot of mental calculations and hand drawn drafts on a piece of paper to be able to write the openscad model. We can’t praise it for that.

        1. You are of course, correct. You can define your objects directly with no inheritance or planning and the resulting code is… garbage. It’s a way of thinking, and no… I don’t use paper. Yes, it requires the ability to visualize what’s happening, but this is my *second* real OpenSCAD project since I graduated from ‘learning’:
          You could probably change 80% of the variables within reason, and everything else will change with it.

    1. I’m assuming by ‘print’ you mean to generate an STL or OBJ for slicing. OpenSCAD can do that, and Thingiverse actually added exactly that for OpenSCAD files recently. It allows you to use sliders, buttons, etc to customize parts and then produce the resulting customized STL files on the fly.

  7. All this once again makes me aware that the logitech mouse software, with it’s programmability and app-aware selectable functions and all that fancy stuff has one bizarre omission: it won’t allow you to assign the scrolling of the scroll wheel.

    Goddamn megacompanies and their bullshit.. sigh.

      1. I’ve been using AHK for many years now, but won’t you know it: logitech has extra buttons not detected by AHK, so you can’t use those as modifier, so sooner or later you run in that nonsense anyway even with AHK :/

        And talking of autohotkey, they really should have added native MIDI devices functionality by now, and detection of secondary keyboards as separate devices like some of the competition seems to be able to do with ease.

  8. One note for those that didn’t notice: In windows when your mouse cursor is over the VLC timeline your scroll-wheel becomes a footage scrubbing scroller instead of a volume adjuster.
    And there are a few more software packages that do that now, position-aware functionality to the scroll-wheel. For example in photoshop scrolling on the picture (with the appropriate settings) zooms it but when you activated the brush size for instance then scrolling changes the size of the brush.
    Thing is though that often it’s not pointed out to people, so you can have a great thing in terms of ease of use but not be aware of it.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.