<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Keith&#039;s Electronics Blog &#187; CAD</title>
	<atom:link href="http://www.neufeld.newton.ks.us/electronics/?cat=30&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.neufeld.newton.ks.us/electronics</link>
	<description></description>
	<lastBuildDate>Fri, 18 Apr 2025 00:10:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Reason #1 to Love OpenSCAD&#8217;s 2D Subsystem:  Fillets</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1730</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1730#comments</comments>
		<pubDate>Thu, 13 Jun 2019 00:05:35 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[CAD]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1730</guid>
		<description><![CDATA[I just designed and printed a battery holder and I&#8217;m shamelessly reusing this image from the blog post about it to illustrate fillets in 3D design: You might notice that the holder&#8217;s mounting bosses have nice roundy fillets that are standard in professional CAD packages and have been a wee bit difficult to achieve in [...]]]></description>
			<content:encoded><![CDATA[<p>I just designed and printed a battery holder and I&#8217;m shamelessly reusing this image from the blog post about it to illustrate fillets in 3D design:</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_200642_DSC00612_brightness.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_200642_DSC00612_brightness_mid.jpg" alt="3D-printed holder for Makeblock mBot robot LiPo battery" /></a></p>
<p>You might notice that the holder&#8217;s mounting bosses have nice roundy fillets that are standard in professional CAD packages and have been a wee bit difficult to achieve in OpenSCAD until fairly recently.  The ability to design them now is one of two observations in the last week that have really driven my interest in OpenScad&#8217;s 2D subsystem.  If you&#8217;re not interested in OpenSCAD, you&#8217;ll probably want to stop reading now.  (Who am I kidding &#8212; I&#8217;m sure that the two of you still reading are interested in OpenSCAD.)</p>
<p><span id="more-1730"></span></p>
<h2>History of Fillets in OpenSCAD</h2>
<p>Fillets are ubiquitous in professionally-designed and professionally-manufactured products.  A fillet is a rounded-over edge, and the term applies to slightly different effects on exterior and interior edges.  A fillet on an exterior edge removes some material to round it over, as though you used a file to smooth the edge, and makes it feel nice instead of scratchy-scrapey.  A fillet on an interior edge, like at the bottom of a recess, adds material to round it over, as though you applied caulk to an inside corner and smoothed it out with your finger, and removes or reduces the tendency of material to crack and break at that sharp edge.</p>
<p>At the time of writing, OpenSCAD doesn&#8217;t appear to have a native fillet operation.  Techniques used to accomplish fillets in OpenSCAD in the past include (in my order of awareness of availability of the features as the software developed):</p>
<ul>
<li>Construct filleted <em>boxes (exterior fillets)</em> <strong>out of 3D primitives</strong>, with spheres at the corners, cylinders for edges, and rectangular prisms for faces.  This was &#8230; tedious.</li>
<li>Construct <em>filleted boxes (exterior fillets)</em> by <strong>applying a <code>hull()</code> operation around a sphere in each corner of the box</strong>.  This gives good results with good performance but it still requires quite a bit more code than what one would rather be able to write as concisely as <code>fillet(r = 3) cube(size = 10)</code> .</li>
<li><em>Fillet the edges of boxes (exterior fillets)</em> by <strong>using <code>minkowski()</code> to &#8220;puff out&#8221; the exterior of a box by the 3D footprint of a sphere</strong> (or other shape of choice).  This tends to take <em>quite</em> a lot of computation and requires drafting each edge of the box smaller by the radius of the sphere used in the Minkowski operation.</li>
<li>Construct <em>filleted recesses</em> by <strong>using <code>difference()</code> to carve a shape</strong> created with any of the above techniques <strong>out of a larger object</strong>.</li>
<li>Learn to use any of a variety of <strong>user-contributed modules and algorithms</strong>, with varying strengths and weaknesses in effect and performance.</li>
</ul>
<h2>offset() Operator in 2D</h2>
<p>Lately I&#8217;ve been using the <a href="https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Transformations#offset"><code>offset()</code> operation in the 2D subsystem</a>.  I wish I could find where I first ran across using this for fillets, because I&#8217;d like to give credit for the idea that predates the nice diagram you&#8217;ll now find in the manual.</p>
<p>The idea is simple &#8212; to round over an exterior corner, offset the perimeter inward by the fillet radius (shrinking the part) and then back outward by the fillet radius (restoring it to original size).  When it&#8217;s expanded back out, the radius won&#8217;t &#8220;reach&#8221; all the way to the original sharp corners, so they&#8217;re smoothed out.</p>
<p>Rounding over interior edges uses the opposite order of operations from rounding over exterior ones, and is what I used in my battery holder:</p>
<p><code>offset(r = -fillet) offset(r = +fillet) {<br />
&nbsp;&nbsp; union() {<br />
&nbsp;&nbsp;&nbsp;&nbsp; posts_2d_with_hull();<br />
&nbsp;&nbsp;&nbsp;&nbsp; flange_2d();<br />
&nbsp;&nbsp; }<br />
}</code></p>
<p>This creates the nice curves where the mounting bosses join the perimeter wall.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/12/20190612-LiPo-battery-holder-screenshot.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/12/20190612-LiPo-battery-holder-screenshot_mid.png" alt="OpenSCAD model of Makeblock mBot LiPo battery holder" /></a></p>
<p>I&#8217;m very happy with this approach for the things I&#8217;ve been designing lately.</p>
<p>The astute reader will have noticed that the availability of <code>offset()</code> only in the 2D subsystem means we can only fillet in the X-Y plane.  Which is true, <em>but</em> <a href="https://www.thingiverse.com/thing:2443544">Thingiverse item 2443544</a>, nominally a simple clip customizer, demonstrates intersecting the extrusion of a filleted shape in the X-Y plane with the extrusion of a filleted shape in the X-Z plane to yield a 3D shape filleted in multiple planes.</p>
<p><a href="https://www.thingiverse.com/thing:2443544"><img src="https://cdn.thingiverse.com/renders/54/78/fd/54/b4/61a2e63249ab88e70428674af70f3eb6_preview_featured.jpg" alt="preview of Thingiverse item 2443544" /></a></p>
<p><em>This image is copyright 2017 by Thingiverse user Torleif and is embedded here under the Creative Commons &#8211; Attribution license.</em></p>
<p>The blue extrusion is drawn (and filleted) in the X-Y plane; the pink in the X-Z (in fact, just <em>drawn</em>, then extruded, then rotated as though it had been extruded from the X-Z plane).  Then the two are intersected to get the final, grey shape.</p>
<p>This doesn&#8217;t solve everything &#8212; for example, a professional CAD package allows filleting the curved edge of the grey clip, whereas this method can only fillet the edges of outlines.  Nevertheless, this extends even further the possibilities already offered by using <code>offset()</code> to fillet and is a very useful technique.</p>
<p>So fillets have me pretty interested in designing my OpenSCAD objects by drawing and filleting them in 2D, then extruding into solids.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1730</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D-Printed Makeblock mBot LiPo Battery Holder</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1715</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1715#comments</comments>
		<pubDate>Wed, 12 Jun 2019 23:10:26 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[Robotics]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1715</guid>
		<description><![CDATA[I&#8217;ve assembled a couple of Makeblock mBot robots I picked up a few years back and intend to start programming soon. They come with a 4xAA battery holder, but I&#8217;m not a fan of single-use batteries and Makeblock&#8217;s LiPo is only $10 on Amazon [no affiliation and not an affiliate link, just a happy customer], [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve assembled a couple of <a href="https://www.makeblock.com/steam-kits/mbot">Makeblock mBot robots</a> I picked up a few years back and intend to start programming soon.  They come with a 4xAA battery holder, but I&#8217;m not a fan of single-use batteries and Makeblock&#8217;s LiPo is only <a href="https://www.amazon.com/gp/product/B07KPVH8H3/">$10 on Amazon</a> [no affiliation and not an affiliate link, just a happy customer], so I ordered a couple.</p>
<p>The LiPo batteries came in clear plastic cases with tabs that looked like they should latch into the slots on the robot chassis, but the spacing was off.  The robot kit came with hook-and-loop tape to fasten down the battery holder, but yuck.  So I designed this holder, which is good enough to use after a single pass of dimensional refinement.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_202346_DSC00625.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_202346_DSC00625_mid.jpg" alt="Makeblock mBot robot with 3D-printed LiPo battery holder" /></a></p>
<p>Many thanks to my student employee Kip for printing the battery holder on his Prusa I3 MK2s.  The quality is outstanding.</p>
<p>I&#8217;ll upload the design to Thingiverse after a bit of code cleanup.</p>
<p><span id="more-1715"></span></p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_200642_DSC00612_brightness.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_200642_DSC00612_brightness_mid.jpg" alt="3D-printed holder for Makeblock mBot robot LiPo battery" /></a></p>
<p>The battery holder is a fairly simple box with a notch at each corner for the wires to exit and a mounting boss in each corner to screw it to the chassis.  I designed 3.8-mm holes in PLA to thread in M4 screws without tapping; and at least for a single installation, it&#8217;s a nice snug fit without feeling like it&#8217;s going to crack the plastic.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_202014_DSC00624.JPG"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2019/06/11/IMG_20190611_202014_DSC00624_mid.jpg" alt="Underside of Makeblock mBot robot" /></a></p>
<p>The motors were in the way of tightening the screws from below, so I had to almost entirely disassemble the mBot to install the battery holder.  But the mBot purportedly has LiPo charge management on its motherboard, so this should never have to be removed again until the LiPo is used up and needs to be replaced.</p>
<p>With all that unused space underneath, one (I) might think that the battery should be mounted below the chassis, and one (I) might be inclined to agree.  But I didn&#8217;t spot a good way to mount it securely without either modifying the chassis (nope, at least not yet) or adding long rails to the holder to get to existing mounting holes.  So up on top it is.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1715</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Notching a Circle in Inkscape</title>
		<link>http://www.neufeld.newton.ks.us/electronics/?p=1489</link>
		<comments>http://www.neufeld.newton.ks.us/electronics/?p=1489#comments</comments>
		<pubDate>Sat, 03 Mar 2012 16:00:13 +0000</pubDate>
		<dc:creator>Keith Neufeld</dc:creator>
				<category><![CDATA[CAD]]></category>

		<guid isPermaLink="false">http://www.neufeld.newton.ks.us/electronics/?p=1489</guid>
		<description><![CDATA[I needed an SVG and DXF of a circle with notches around the perimeter to laser-cut a diffuser lens and to subtract the lens&#8217;s shape from its housing in OpenSCAD. The best tool I had for the job appeared to be Inkscape (in part because I really wanted to do it with an open-source tool [...]]]></description>
			<content:encoded><![CDATA[<p>I needed an SVG and DXF of a circle with notches around the perimeter to laser-cut a diffuser lens and to subtract the lens&#8217;s shape from its housing in OpenSCAD.  The best tool I had for the job appeared to be Inkscape (in part because I really wanted to do it with an open-source tool so it could be repeated by others), and the method was quite a process of discovery, aided greatly by John Harrison.</p>
<p>Here&#8217;s how I did it.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/0-circle.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/0-circle.png" alt="Inkscape circle with position and dimensions" /></a></p>
<p>Draw the circle and use the toolbar transforms to set its diameter and position it at the origin.  (Since positioning the notching figure correctly on the circle must be done in absolute coordinates, it&#8217;s easier to calculate with the circle centered at the origin.)</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/1-notch.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/1-notch.png" alt="Inkscape circle and notching square with position and dimensions" /></a></p>
<p>Draw a shape you want to use to notch the circle (in my case, a square rotated 45 degrees) and use the toolbar transforms to position it to notch the circle (in my case, overlapping by 0.100&#8243;, by setting the X coordinate to half the circle&#8217;s diameter minus 0.1&#8243;).  The next step will be easier if you also size the shape so that its bounding box (enclosing rectangle) is an even number of the units you&#8217;re using in your coordinate system (inches).</p>
<p>I had hoped, by the way, to do this by insetting a circle by 0.1&#8243; (but I can&#8217;t find how to inset by a distance other than pixels, nor to set my inset distance numerically other than zoom way in and watch the mouse position while I drag the inset control point) and then snapping the square&#8217;s position to the inset circle (but Inkscape doesn&#8217;t appear to snap to geometry).</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/3-try-clone-one.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/3-try-clone-one.png" alt="" /></a></p>
<p>What I tried next did not work &#8212; moving the square&#8217;s pivot point to the origin and creating 16 tiled clones of the square with -100% shift X per column and -22.5&deg; rotation per column.  (I&#8217;ll show those steps later when I describe what actually did work.)  For some reason, Inkscape acts as though my pivot point is 0.1045&#8243; left of where it actually is, and I&#8217;m not willing to fuss with manually calculating the (in)correct pivot point every time I want to tile by rotation.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/2-duplicate-notch.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/2-duplicate-notch.png" alt="" /></a></p>
<p>Instead, duplicate (<code>Edit</code> / <code>Duplicate</code> or copy/paste) your notching figure and move the copy to the far side, opposite your original, rotating it 180&deg; if need be.  Positioning the second notching shape is where the integer-unit-sized bounding box comes in handy &#8212; I placed mine with an X coordinate of negative (half my circle&#8217;s diameter minus the inset amount plus the notching obect&#8217;s box width), or -(4.350&#8243; / 2 &#8211; 0.100&#8243; + 1.000&#8243;) = -3.075&#8243;.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/4-group.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/4-group.png" alt="" /></a></p>
<p>Select and group (<code>Object</code> / <code>Group</code>) the two notching figures.  The next step only works on a single object, not on multiple selected objects.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/5-clone-tile.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/5-clone-tile.png" alt="" /></a></p>
<p>With the grouped notching objects still selected, enter the tiled clones dialog (<code>Edit</code> / <code>Clone</code> / <code>Create Tiled Clones...</code>).  On the <code>Symmetry</code> tab, leave <code>P1: simple translation</code> selected, click the <code>Reset</code> button in the lower left to set everything to defaults, and change the number of columns in the <code>Rows, columns</code> to half the number of notches you want (since you&#8217;ve grouped two notching figures together already).  On the <code>Shift</code> tab, set <code>Shift X</code> to <code>-100%</code> per column.  On the <code>Rotation</code> tab, set the <code>Angle</code> <code>Per column</code> to -360&deg; divided by the number of notches you want (-360&deg; / 16 notches = -22.5&deg; / notch).  (Apparently Inkscape rotates clockwise for positive angles, the opposite of the entire field of mathematics.)</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/6-clone-tile-results.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/6-clone-tile-results.png" alt="" /></a></p>
<p>Click the <code>Create</code> button, note that the lower left of the dialog box tells you how many tiled clones have just been created, and slide the dialog box out of the way to view your results.  If it&#8217;s not what you expected, click the tiled clones dialog&#8217;s <code>Remove</code> button and review and retry your tiling configuration until you get what you want.  Once satisfied, close the tiled clone dialog box.</p>
<p><em>Immediately</em> delete (<code>Edit</code> / <code>Delete</code> or press Delete) the selected figure.  The tiled clone tool leaves your original figure selected and makes a copy of it at the original position; you want to delete the original before continuing.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/7-ungroup.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/7-ungroup.png" alt="" /></a></p>
<p>Select everything (<code>Edit</code> / <code>Select All</code> or Ctrl&nbsp;A or drag a box around everything) and ungroup (<code>Object</code> / <code>Ungroup</code>) to isolate your notching figures, as the next step operates on only two shapes at a time.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/8-notch.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/8-notch.png" alt="" /></a></p>
<p>Select your circle and one of the boxes and do a path difference operation (<code>Path</code> / <code>Difference</code> or Ctrl&nbsp;-).  This should carve your notching shape out of the circle.  If instead it carves the circle out of your notching shape, undo, then select the circle and lower it to the bottom (<code>Object</code> / <code>Lower to Bottom</code>) before continuing.</p>
<p><a href="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/9-notches.png"><img src="http://www2.neufeld.newton.ks.us/images/electronics/2012/03/03/9-notches.png" alt="" /></a></p>
<p>The notched circle should remain selected after each difference operation.  Continue selecting additional notching figures and taking the difference until you&#8217;ve created all your notches.  Voilà!  (Or &#8220;Viola!,&#8221; as we say on the Internet.)  A notched circle.</p>
<p>Take care if you intend to move the circle to a specific position on your page:  its dimensions may have changed, as the dimensions shown are those of the bounding box and any notches on the right, left, top, or bottom may have allowed the bounding box to creep in a bit.  You may need to account for this and add a tiny offset to get the center where you want if you&#8217;re positioning the notched circle numerically.</p>
<h3>Better Ways?</h3>
<p>If you know an easier way to do this, I&#8217;d love to hear about it in a comment.  Please try your method, <em>right now</em>, before posting a suggestion.  It&#8217;s too easy to think something will work, or think you remember the exact details, and with the best intentions still mislead people.  Always <em>always</em> <strong>always</strong> test your technical advice before posting it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.neufeld.newton.ks.us/electronics/?feed=rss2&#038;p=1489</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
