Monday, October 24, 2022

2D to 3D, using just Blender

One of the useful tricks for board game pieces is figuring out how to create a 3D object from a 2D image. I did an earlier version of this, using a different process. If you have the SVG file of the object, you can skip to Step 4.

 

Step 1 - Get a straight-on shot of the piece you will be making

The best objects are photographed from directly in front of the object, in good light, with enough resolution to trace the object well.

Step 2 - Importing the file

First, hit 7 on your keypad to orient the view to looking "from above". Next, shift-a will add an (i)mage, and use reference or background - choose your image.

It's useful to have the image in the center, and then to angle it so that it appears straight on. Use (g)rab and (r)otate to move the photo around.


Step 3 - Create the outline

Make sure to be in object mode - if you're in edit mode, it adds new meshes to the existing object selected. shift-a to add a plane, then (s)cale it down so that it fits to the object you are tracing. (Tab) will drop you in and out of edit mode. At this point, choose "select mode vertex" so anything you click on with your mouse will only pick up a corner. (d)elete 3 verticees, and then select the last vertex.   


Now, just (e)xtrude from the selected point around the entire object. If something doesn't quite match, you can use (g)rab to move the vertex around. To connect the final vertex to your original, just select both (shift and click to select more than one) and (f)ace to create a line.

For finer detail, add more vertices to the area. If not enough vertices were added in the first pass, select two adjacent vertices, control-e (or choose the edge menu), and subdivide it. More subdivisions, more vertices.

For less detail, choose one or more vertices, (x), then dissolve vertices.

This meeple needs a flat & even surface for its feet. Select the meeple's base vertices.


On the menu bar, there is a Transform Pivot Point, choose "Active Element". (s)cale (y) (0) will scale all 4 points on the y-axis to the "y" position for the last vertex selected.


Step 4 - Make a face and extrude to make an object

Still in edit mode, (a) will select all vertices. (f) will create a face connecting all of the selected vertices. Next, (e)xtrude (1) to extrude the face along the z-axis. (If it doesn't lock to the z-axis as a blue line, then (z) will lock/unlock it.)

Holding the center mouse button, then moving the mouse will change the view (the keypad 7 had locked to the view from above).

Step 5 - Adjust the total size of the object

(Tab) to go back to Object Mode. Click on "Item" from the side tabs.


Adjust the x-axis or y-axis to a known measurement. In this case, the y-axis measurement for the meeple's height is 16mm - adding that to the Dimension Y box skews your meeple along the y-axis. Copy the "scale" for y to the scale for x, to keep your x&y scale the same. Measuring the thickness of the meeple, adjust the Dimension Z box to 10mm.

To clean things up at the end of the process, select Object>Apply>Rotation & Scale to set the "scale" for x/y/z to 1. Sometimes slicer software expects this, and it is a good habit to get into regardless.

Step 6 - Export the object

File>Export>Stl will export the selected object as an .stl file, useful for 3D printing.

Conclusion: 2D is now 3D!

It's straightforward, it's brute-force, but it is also done.

Extra Credit: Using the Mirror Modifier

There are more tricks than what was shown here. The meeple is technically the same on its left and right sides, even though the outline isn't the same. Instead of drawing out the complete outline in Step 3, you can get by with only doing one half, then mirroring it.

 


Disclaimers: Have the "edge" to be mirrored directly on the x- or y-axis. Scale must be "1" and rotation 0 degrees following the process at the end of Step 5. The object's origin should be at 0/0 for the best results.

(Tab) to Object Mode and select the object. Click on the wrench for Modifier properties, and scroll down to Mirror under Generate. The default mirror is the x-axis, which gives the proper mirror for this meeple's other half. Check the "Clipping" box, so that the two halves merge at the mirroring line. Resume the design process back at Step 4.

      

Monday, July 26, 2021

Bang. Lulzbot Mini stops printing

 I still run two Lulzbot Minis, 1.04. They're durable and dependable.

Except for two weeks ago.

The BANG

I was making some custom Magic the Gathering coasters for a friend's birthday party. The last one to print was the Swamp icon, except...I was down to 1 meter of black filament. I thought I would be clever and do a two-tone. If you haven't read my earlier material, I covered doing it here.

When I switched over from gray to black, it went smoothly. I tried resuming the print from the Octoprint web page - and it choked. The nozzle crashed down onto the printing plate and I aborted. [Note to self: resume it from Cura next time?]

Future prints, it would run into an error during startup.

It would touch the first washer (front left), TRY to touch the second washer (front right) - but fail. At this point it would cancel the job.

Possible solutions:

  1. Nozzle is old and needs replacing - but it was making a connection on the first one
  2. Wire for the bed was broken - apparently the wire can be broken inside its casing
  3. The board was somehow corrupted and needed to be reflashed
  4. Bed was out of alignment - seemed reasonable from the crash
  5. Toolhead was out of alignment - also reasonable from crash
Nozzle is an easy but time-consuming replacement - I'd come back to that if needed.

Replacing the wire was unfamiliar to me, but I would do it if necessary.

Likewise, the brains (the board) - reflashing it is something I had never done.

And then I found this page - adjusting the "x" axis, which is the vertical. (Fixes the toolhead being out of alignment.)


It took some effort to get a good measurement, but it was easy enough to adjust.

Best of all it might even fix my 1.03 that's been sitting in a box for several years. Woo-hoo!

Adding Octoprint to Home Assistant

I still 3D print - home automation took over some of my time. It's still relevant to 3D printing though.

The useful links to my 3D Printing-related Home Assistant posts

Home Assistant Controlling Octoprint through MQTT - Chapter 1 

Home Assistant Controlling Octoprint through MQTT - Chapter 2 

Adding controls for the smart plug - also shows the dashboard

The benefits are nice - I can turn on the two printers, start the connection from Octoprint, preheat the nozzle, extrude, retract...my printers don't have LCD screens or manual controls.

The costs are not that much - a Raspberry Pi 3+ for Home Assistant, a 2.5 Amp plug for the Pi, and the Kasa Smart Plug if you go that route. Mostly time to get into it.

Thursday, May 14, 2020

Easter Traditions: the Dinobunny (and Sculpting 101)

My girlfriend likes dinosaurs. We have a wacky, inflatable dinosaur that's about two-and-a-half feet nose-to-tail, that got paper-crafted bunny ears at some point. I'll also state this post will feel very dated, as my sculpting abilities progress.

The Great Dinobunny. Every year, he'd hide plastic eggs around the apartment, containing a variety of objects. Some years it was candy, sometimes little dinosaurs or other toys. This year, I printed some eggs (we moved 4 months ago, not sure where things are), and the avatar of the Great Dinobunny.
Avatar of the Great Dinobunny

The project started with the 13 eggs from this design on Thingiverse.  They're a lovely design, printed well 95% of the time, a little longer/thinner than previous eggs - fine for the purposes.

Next, was the 3D Bunny Puzzle by Sakati, also on Thingiverse. As it's a No Derivatives license, I'm not posting the Dinobunny .stl back out there. The 12-piece puzzle is based on the Stanford Bunny, basically a project in 1994 where they tried to 3D model a bunny as accurately as possible for a computer to display. You can read more about it on Wikipedia in this article. I ended up making the dinobunny 13 pieces — I wanted the ear puzzle-piece to be printed white, with the rest of the dinobunny being green.

I printed the puzzle at 50% size, and it was nice. The tolerances were good; not too big, not too little. But for a dinobunny, I needed to do something more. Imported the puzzle into Blender - all of the pieces were imported into their proper space...no dragging needed!

Version 1: Crossbreed
Fixed up the head and the tail - tail was still rough
I haven't done a lot of sculpting in Blender 2.8. Blender 2.79 and lower, I did sculpt several times, but it was never quite natural for me. Blender 2.8, I used most of the same tools, but it just felt better.

Sculpting Tip #1: Turn on Dynamic Topology, aka Dynotopo

When you're in Sculpt mode, it's in the lower right panel, there's a checkbox labeled "Dyntopo". Click that, and your sculpting will look a lot smoother - at a cost of more polygons being created. Also, I've noticed that Dynotopo becomes unchecked when you leave Sculpting mode, at least in my version of 2.8.
Dynotopology off (turn on!) and Symmetry as Mirror is all unselected
Yeah, when you turn on Dynotopo, this is a junk message. Click "OK" and move on


Sculpting Tip #2: Deselect Mirror under Symmetry

It's in the same panel as Dynotopo - immediately below. It's not so much on/off, as select everything off. In the case of the dinobunny, there wasn't anything to mirror - and leaving Mirror X on (the default) made me question my sanity/sculpting.

Sculpting Tip #3: Be aware of what you're sculpting


I definitely did NOT want to affect the puzzle portion. It meant extra care when I was using sculpting tool near the existing puzzle cut outs and tabs.

The new Dinobunny neck

Stretching the neck out was problematic for me. I basically grabbed a bunch of vertices and dragged them up - but it wasn't on a straight z-axis. The next step was making a cylinder with the height of the new neck, with the diameter of the "post" in the puzzle's neck...this served as a guide on grabbing the vertices to the right place. (I want to say I did smart things, like changing the neck pieces to match the rotation face of the cylinder, so I could just "z-z" and move along the object's own z-axis as opposed to global z-axis. It also works to just join the cylinder and the piece you want to move up/down, and then use "p" in edit mode to separate them again. z-z now works for the piece, using the angle of the cylinder.)

Well, you now have a stretched out neck. It no longer looks natural, just a bunch of flat planes.

Before

After
I spent some late night  hours on this, and no longer entirely sure of the process - it's good to document things as you go, so you can be accurate when describing your descent into madness. Remember: dynotopo ON, symmetry OFF. In sculpting mode, the strength & the size of your brush - they're both impacted by how far in/out you zoom in on the model. A feature, not a bug.

Dynotopo was necessary here — I wanted to get the organic, slightly lumpy roundness bits of the original...and it wouldn't make the new faces I needed if I just tried to dump clay strips down.

I also sculpted with non-active pieces visible, as it gave me feedback on how the rest of the pieces looked with the changes. Sculpt mode doesn't affect those non-active pieces, so it was a safe method.

Brushes used:
  • Used Draw more often than Clay Strips, both as a +/- brush.
  • Smooth for cleaning things up
  • Alternating between Crease and Pinch for better definition of transitions

Making Two Pieces instead of One


As I wanted to make the ear portion white, it meant I had to break apart the back of the head/neck piece. I didn't use any sculpting technique - it was a quick creation of a cylinder and cube merged together, and then using Boolean>Intersect on it to make the bottom part. I briefly scaled it up, to then Boolean>Difference to create the puzzle-fit in the top portion. No sculpting needed!

Remaking the puzzle portion - notice my edges are sharp compared to the original




Thursday, April 30, 2020

Zooming in: Remixing a Train Station for Ticket to Ride Europe


Black is my final version, red is from the actual game
(Sorry for the break. We got a house and a puppy. Less writing, more...stuff to do.)

Today, I'm zooming in on a remix I did for a friend. We were listening to irish folk music at a newly-local bar, and one of my friends asks: do you do replacement game pieces? Yes. Yes, I do.

Their copy of Ticket to Ride Europe apparently didn't arrive with black train stations. We went on Thingiverse, found a station - thought, sure...it's already done! Getting home that night, I realized that it was only partially done and unprintable — but someone else had remixed it into a solid piece.

Left is straight import, right is cleaned up
The initial print was fine. It had the general shape and was roughly the same size. In a dark play area, maybe someone wouldn't notice all of the differences. My friend probably would have been happy with it, but if *I* played with them, it would bug me that I didn't improve the piece before gifting them. You can find the final STL on Thingiverse, here.

The final project
I did a lot of touching up. The arch for the train tunnel is now rounded, instead of chunked 5 times. The tall doors/windows on the first floor have a break in them, like the original. Shingles! Oh man. The actual stations have smaller shingles and more of them, but I felt it was risking the details not showing up enough. The overall piece is only 3 cm tall, printed with a .1mm layer height. (That's 300 layers, maybe I could have fit in more detail.) I added the side vertical ridges above the arch, and the time is now the same on both sides. The triangle windows...dormers(?) on the roof needed to be fixed as well.

This was hours of work, using the digital calipers and figuring out how the model was actually designed. Minor trivial adjustments — it's hard for me to let an imperfection stay.

Timesaver Tip 1: Cut it in half, use the mirror modifier

I was adjusting the first floor, the second floor, the pre-shingled roofing...why do it more than once? I should have been able to mirror x-axis and y-axis, which would have been a much better example.

Timesaver Tip 2: Break it up into consumable parts

One of the nice parts about Blender, is keeping the objects separate until the end is easy. The shingles were probably the most fun part of the whole remix - carving them out of the roof would have been annoying though.

The three shingle arrays on the roof

There are three parts to the shingles - the main roof, the top of the clock tower, and the slightly curved shingles at the base of the main roof.  I did the initial main roof tile as a flattened cube, rotated it to match the roof, and then multiple arrays of the cube. As I only needed the tiles that would stay on the roof portion, I grabbed them downward into what they would be covering. Using the boolean-intersect with the main station...it now matched the size of the roof, and raised them slightly back above the main station to be visible. The clock tower shingles were much the same. (Also in keeping with the first timesaver tip - MIRROR.)

The slightly curved tiles, were a single array. The base tile, in  edge mode, I selected the two side edges, control-e for the edge menu, then Subdivide - 3 times. I grabbed the three new edges to make a slight curve...then did the array, followed by the same boolean-intersect trick to get the right amount of tiling.

I didn't bother altering the bottom or sides of the curved tiles - those are hidden inside the roof. I didn't make any special exceptions for the 4 dormers, within the tiling, as the shingles went right up to the dormers.

Overall, I didn't learn a lot of new skills in the project — it is what it is. Looking back, I was too finicky about small details. I could have mirrored x and y, saving 30 minutes here and there. Maybe I could have done the shingles smaller, and still had detailed shingles for the final print.

Wednesday, October 9, 2019

Art Deco Lightswitch Cover and Multi-color Prints

This started off as a project to make a lightswitch cover that was interesting and unique. We've been looking at buying a house, and when I mentioned that maybe doing custom ones would be fun — yes.

For this project, I used Blender 2.8 and older developer version Cura (2.x, but is able to run on an ancient OSX desktop). The file can be found here - https://www.thingiverse.com/thing:3907742

Lightswitch Cover Design & the Foray into Art Deco


It would have been an easier start if I had just remixed someone else's lightswitch cover as a base. In this case, I decided to do everything from scratch. Starting with digital calipers, I decided the plate would be 114 mm tall and 71 mm wide. I measured the slot and the holes, using blocks and cylinders to punch holes in the plate. (The cylinder was wider at the top, to represent the tapered screw that lightswitches use.)

I did some beveling on the top and the underside to get a rounded feel for the cover — one of the useful techniques when using control-B to bevel, or Edge>Bevel Edges is using "M" to change the mode...I clicked M several times to get to "percent", which turned out really well. I've done some basic bevels in the past, but this is the first time I experimented with every combination of options before settling on the one true way.

Added some cylinders on the bottom for more screw support. The bevel on the actual bottom came from inset, followed by moving the portion up past the top's bevels, then applying bevel/percentage to the rectangle that had moved up. Tricky.
Before printing this cover, I downloaded someone else's plate from thingiverse, compared the slots and holes...pretty close. I did end up moving the screw holes .3mm closer to the center, but not bad. Printing it, I realized I had not put enough taper space into the plate for the screws. Ah well.

With the basic object shape out of the way, we get into an introduction of "art deco". As I'm not a designer, I went to Google Images, and searched for "art deco pattern". After browsing a ton of images and styles, I decided on one that was relatively simple. (Showing my beta version to an actual designer type person, he asked if I was a designer, and explained that I got the style right - basically a simple image that repeats...that's what I got out of his comments at least.)

The goal was an image that would merge together with itself. Didn't like my design at first, but it looks good printed. 

I created the basic image, sized it up to 15 mm, then used the array modifier for the relative offset y-axis at "1.25", 20 times. I created a second array modifier, .65 for x-axis, .025 y-axis. This wasn't science, it was trial and error to get a feel for what it would look like.



Next was...ugly. I clearly need to learn better habits on how to merge the art deco design onto an object.  It *eventually* worked. I needed to use a lot of the 3D Print Toolbox plugin to look for non-manifold edges. There were over 300, and I did too much manual fixes and partially manual fixes to get down to 0.

Multi-color Prints & How to Pause in Mid-print


A friend asked me how hard it was to imbed something within a print. Specifically, adding a metal nut into a knob as it prints. Sure, it could be done, but I didn't know how or had a project that needed me to stop in mid-print...until NOW.

The idea was to print the art deco image in a different color - imagine a white plate with a series of black stamps. There's a plugin that comes native to Cura, found under Extensions>Post-Processing>Modify G-Code>Add a script>"Pause at height". From Blender, I recognized I needed about 5mm of white before switching over to black. Loading the cover, clicking on the View, Layers...it looked like I needed to switch over at layer 21, at a .24 mm layer height. The only number I had to change for the input was the Pause Height to 5.04mm (arrived at by multiplying 21 * .24).

[edit: I came back a year later to update some of this.]

If you have a different initial layer height, make sure that is figured as layer 1. (For example, a .3mm layer height, and 20 layers at .24...5.10mm.) You can also resume the print from your Octoprint browser window, if you don't have Cura open.

I'm trying out "Extrude Amount" with a new print - it's supposed to extrude filament after you resume. You'll still need to be quick, to clean off that extruded filament before it starts printing on the model.

[edit end. November 29th, 2020.]

You can add multiple pause at heights, for multiple color changes from highest (top) to lowest (bottom).


And I started the print. At layer 21, the printer paused and sent the printer head to the far right corner, and elevated on the z-axis slightly. The Cura software was still open, and registered as "Paused". I opened up the tensioner on the feeder, slowly pulled the white filament out, slowly pushed the black filament through. Caution! Try hard not to move the printer head - if it loses where it is, it won't be aligned when it starts with the new color. (If you look closely, you can see white at the top of each black circle, where I bumped it slightly when using the feeder gear to push it through. The second time, I just pushed it through manually, no gear.)

Going back to the Cura software, it was still paused. Click the resume button, and it goes back to printing. Sadly, my bed temperature was low for PETG (and the room was drafty), so you can see how the corners were pulling up. That's fine for experiments, but wouldn't be good for the final result.

Action shot, printing the black as layer 21

I also found that the cover no longer printed correctly. The screw holes and switch slot in the cover filled on some of the layers! Sure enough, back in Cura in View Layers, I noticed that it filled up. Spending some time in internet searches, the solution that I found suggested in the "Mesh Fixes" options, to DISABLE "Union Overlapping Volumes". That brought back the holes and slot that should have been there in the first place.

The screw holes are white, the switch was black...clearly neither were holes anymore This version had beveled edges on the outside, which meant they ended lower than 5.04 mm (still the white filament).

Having done that, I went back to printing the white/teal PETG to get this final product. (230 degrees nozzle, 70 degree plate, .24mm layer height, .5mm nozzle.) Polymaker's Polylite PETG, 2.85mm.

Ta-da!


Wednesday, September 25, 2019

Removing the background & converting a JPEG or PNG to SVG

Disclaimer: this isn't a strictly 3D printing post. Blender will consume SVG files, and with some effort can MAKE svg files...but I needed some SVG files for a project, so I will go over how it works for me.

For my current project, I need to remove the background of a photo, then turn the subject into a SVG file - all so I can use a laser cutter to etch animals onto slate coasters. 



I'll be using Illustrator...CS3. I was a student once, and the Indesign/Photoshop/Illustrator package was $300 as a one-time purchase. I'm not using this for commercial purposes (if I end up needing to do commercial purposes, I might come back and show how to do this in Inkscape). I'm sure the habits are very similar.

I start with a 10 cm x 10 cm square as the document size - the size of the coaster I'll be etching with a laser. (This can also be useful for someone using a Cricut - my girlfriend got one last week.)

Next, under File>Place, I put my image file on my document - this also creates the first layer. The image is ideally too big - scaling down keeps details, while scaling it up will lose them. Regardless, select a corner with your right mouse button, hold down shift (so the image will scale on its X/Y at the same rate)...and then scale your picture to fit in the box. If you used a PNG, you're fine. If you used a JPEG, go to Object>Rasterize and click okay in the dialog box. (If you don't rasterize your JPEG you will not see "Live Trace" later.)

Rasterized Baby Leopard scaled down to fit in the 10 cm x 10 cm frame (Layer 1)
You have the photo within the box - let's take a step back and do some other prep work. Under Window>Layers - you'll want that visible. Under View>Show Transparency Grid, you want the background to be transparent - checkered instead of pure white. Also under View>Smart Guides, I like turning those off for this kind of project. (Feel free to turn them back on later - you can decide for yourself what you like.)
View Menu for adding Show Transparency Grid & turning off Smart Grid

As a good practice, create a new layer and select it - this is where you'll do your tracing. Both your foreground and background should be a white box with a red line through it...this means any fill you have will be transparent. (If you don't do this step, you'll see your picture being covered up as you trace.)

Transparent fill
With the pen tool, start right-clicking along the border of your image. You can make curves with a curve tool, but...more learning. When I hit an area that needs more of a curve, I'll just place more vertices. Once you get back around to the start, click from your first spot, and it will automatically make it complete. (If you had Smart Guides from earlier turned on, it would try to suggest certain angles for the next vertex.)

The red vertices are pretty small, so I often zoom in for close details

With that done, drag that part of the layer 2 on top of that the original layer. Under Select>All, it should highlight both the image and the border you just drew. Object>Clipping Mask should cut out the background!

The clipping can be more exact, but the conversion to SVG will change the detail level too.
Now comes a more basic "turn this into an svg" - you can always save an Illustrator file as an SVG. But I needed a black with transparency object. With the selection tool (not pen tool), double right-click on the new image. You want a "Live Trace" button to show up in the top bar, and for some reasonable-but-not-known-to-me, it takes two double-clicks. Press "Live Trace". Boom - white and black...but not transparent. There's a button in the bar that opens up tracing options, and you'll want to check the "Ignore White" checkbox. (You'll notice now that it's just transparent and black now.) I would also recommend experimenting with different amounts of Threshold, instead of sitting at 128. The higher the number, the more black. Min. Area is going to give you a higher detail at a smaller number.

Trace Dialog Box

And that's it. Save as a SVG, and you're done! Wish you good luck translating this into your vector-based experiences.