Crowd-Sourced List of Python Resources Related to Halloween

An AI-generated image. bats fly overhead, with a full moon visible. On the left is a laptop showing some computer code. In the middle is a pumpkin with the Python logo carved in it. There is also a black cat with green glowing eyes. If you look at this blog, you’ll quickly see that many of my projects relate to Halloween. I don’t know if this is a good, bad, or dumb idea, but as I was thinking about my use of Python for controlling Halloween props, I had the thought that it might be nice to have and share a crowdsourced list of python-related resources relating to Halloween, such as useful libraries (e.g., pyAudio, various libraries for using the GPIO pins on a Raspberry Pi), complete software packages (e.g., my own ChatterPi), or even Halloween-themed games written with Python. So, with some help from ChatGPT, I’ve put together a Google sheet, Python Resources for Halloween,  with some pre-populated content that anyone can view, along with a Google Form, Submit Python Resource for Halloween, where anyone can submit additional resources for inclusion.

The submissions are moderated, so they won’t show up immediately in the resource sheet. If you have anything to propose adding, please do so using the Google Form. If you have any other feedback, I welcome it as a comment on this post.

Quick Post #6: Bears Go Punk!

I’ve been pleasantly surprised by the uses around the house that I’ve found for the 3d printer my wife got for me last Christmas. This is about one such use. A couple of years back we saw some silhouettes of black bears in a yard while we were on vacation in the Great Smoky Mountains. I found patterns for some online and with plywood, jigsaw, and paint, we made a mama bear and two cubs. We love them, and they drew a lot of attention and positive comments from our neighbors. Unfortunately, the birds also like them, perching on them and doing their business. My wife had the good idea to look into spikes, but then the question was how to attach them. Our son suggested 3d printing clips. I modified that a bit into brackets, and we were in business.
Rubber spike strip

Plastic spike strip, which has three segments and flexes between them.

A still frame of the plastic clips being printed inside the 3d printer

Printing the clips on my printer

Plastic bracket with a slot for plywood to fit between and a base.

The bracket design, a modification of a plywood bracket that I found online.

This is the bracket. I found a plywood stand design online. The base was too large, but I liked the fillet where the supports meet the base and the slot was already pre-sized for 1/2″ plywood.
I couldn’t just scale the design, since it wasn’t parametric and shrinking it would also shrink the slot opening. Instead, I just used TinkerCad to cut off the excess on all four sides.
The 3d printed brackets were a great solution for the question of how to mount the strips. The strips aren’t invisible, but with their black color they don’t jump out too much, either, and I think the silhouettes still look pretty good from a distance. Time will tell what the birds think.😊
What uses around the house have you found for your 3d printer? Please share in the comments.
A plastic spike strip with two brackets glued onto the bottom

One of the plastic spike strips with two of the printed brackets glued onto the bottom, ready for installation.

Black plywood silhouette of a bear, with three spike strips mounted on top.

Mama bear sporting her new punk haircut

Plywood silhouettes of a mama bear and two cubs. Spike strips are mounted along the top of each bear.

The spike strips aren’t invisible, but they don’t stand out either. I think they still look pretty good from a distance.

Quick Post #5: A Utility for Converting .obj Files Created by Microsoft 3D Builder

There are several different file formats for specifying 3d objects (as Tannenbaum wrote, “The good thing about standards is that there are so many to choose from.” One such standard is the obj or .obj open format. By itself, the .obj file definition does not support coding surface shading properties in the .obj file, but these can be provided in a separate Material Template Library (.mtl) file.

While not part of the official file format, many program support vertex coloring by adding the RGB values for color to the end of the relevant vertex line. The de facto “standard” for this non-standard usage is to code the RGB values as decimals between 0 and 1. However for some reason, Microsoft’s 3D Builder codes them as integers between 0 and 255. As a result, other programs, e.g., Bambu Studio, while capable of using vertex coloring using values between 0.0 and 1.0, won’t read the color information when you import such a file. This simple script converts the RGB values from a range of 0-255 to a range of 0.0 – 1.0 and writes out the modified file. Here’s the code, which is also published as a Gist:

import sys

def convert_obj_vertex_colors(input_file, output_file):
    with open(input_file, 'r') as infile, open(output_file, 'w') as 
    outfile:
        for line in infile:
            parts = line.strip().split()
            if parts and parts[0] == 'v' and len(parts) == 7:
                # Convert RGB from [0, 255] to [0, 1]
                r, g, b = map(float, parts[4:7])
                r, g, b = r / 255.0, g / 255.0, b / 255.0
                outfile.write(f"{parts[0]} {parts[1]} {parts[2]} {
                parts[3]} {r:.6f} {g:.6f} {b:.6f}\n")
            else:
                outfile.write(line)

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("Usage: python convert_obj_rgb.py input.obj output.obj")
    else:
        convert_obj_vertex_colors(sys.argv[1], sys.argv[2])