Posts

Use IA for 2D nesting, they said ...

Image
Well, I have gone down the rabbit hole of applying IA to solve free-form 2D nesting problems, but the results weren't what I expected.  However, I have learned a lot of things in the process, and created some software you might find useful, such as this  packer , which has nothing to do with AI (initially), but it is a basic Left-Bottom First packer.  The AI part comes in when you provide it with a somewhat "intelligent" parts sequence. And there, my friend, is where many different attempts and hours of AI training went. Let me explain what I did and how I did not accomplish much in the process: I had a collection of 2D part geometries and the results of a professional nesting tool applied to them. I thought I could use that to teach a model how to tell a dumb LBF to do better by either providing the optimal part sequence and/or rotation angle. I used different approaches to that, but I underestimated my ability to mess things up, so I ended up with six different transfor...

The problem with Clonezilla ...

Image
 This is just a reminder, as I seem to stumble with the same rock every now and then. The problem is the keyboard configuration and the sometimes quick time window to perform a cloning operation. All of it leads me sometimes to a number of failed attempts until I got it right. The culprit? Having passwords that use symbols that are mapped to different keys depending on the keyboard language selected. And no, selecting the UI language has nothing to do with that.  So the common symptom is my host system no longer allows the connection to the SMB share I use to store the images to (or to retrieve them from). So I first worry about potential incompatibility of the SMB versions and authentication modes. Then I think there might be I am not remembering a not so often used password right. And, eventually, I realized that the password I am typing at the terminal that I cannot read as it is not echoed back most likely contain the wrong symbols as I did not choose the right keyboard (w...

Using PyMeshLab

Image
This document summarizes some of the usage of the pymeshlab library. Unfortunately, the library has been through severe changes over time, so some methods are renamed and filter calling conventions are shifting too, which makes AI and humans mad :-) Core Concepts The MeshSet The MeshSet is the primary container for handling multiple mesh layers and applying filters. ms = pymeshlab.MeshSet() Mesh Objects Individual meshes within a MeshSet . They contain the geometry and attribute data. mesh = ms.current_mesh() Basic Operations Loading and Saving # Load a new mesh into the MeshSet ms.load_new_mesh("input.stl") # Save the currently selected mesh ms.save_current_mesh("output.stl", colormode=False) Layer Management # Get total number of meshes in the MeshSet count = ms.mesh_number() # Select a specific mesh by index ms.set_current_mesh(1) # Delete the currently active mesh ms.delete_current_mesh() # Control visibility (often used for merging) ms.set_cu...

The Problem: Why Batch Files Fail

  I recently encountered an unusual error when trying to pass certain filenames to a Python app as inputs. After a moment, I realized the troubled ones had a comma in their filename, which should be totally valid, isn't it? It turns out Windows Batch ( cmd.exe ) is built on legacy rules where the comma ( , ) , semicolon ( ; ) , and equals sign ( = ) are treated as delimiters, exactly like a space . When you drag a file named Data,Project.txt onto a .bat file: Explorer sends the raw string to the command processor. CMD sees the comma and splits the filename into two arguments: %1 becomes  Data  and %2 becomes Project.txt . The comma is deleted from the stream entirely ( 🤦 ). The Solutions: From Hack to Hero Method The "Ugly Hack" (Batch) The "Robust" Way (Shortcut) The "Pro" Way (PyInstaller) Setup Create a .bat file with %* Right-click .py > Create Shortcut Compile script to a standalone .exe The Trick python script.py "%*" Edit ...

Remote KVM

Image
I usually have Linux server boxes with only power and network cables. That works well most of the time, except when: You need to install the operating system. You screw up and render the system unresponsive, even after a power cycle. Then you realize you need to move a keyboard, mouse and display to that machine to see what is going on, and hopefully fix it. Not a big deal if you are in the next room, not ideal if you are in another city or country.  So after watching Dave's video , I decided it was time to start using these devices for my own good. And I learned a couple of interesting things while reviewing the features: There is an optional add-on, called Fingerbot, that can be used to act on a push button, like the reset or power button of your server remotely. That way you can even power off a misbehaving server, or power it back on after powering it down. That is especially useful if Wake-On-LAN is not possible at the moment (most computers do not come with that enabled). The...

Browser-based Peer to Peer file transfer

Image
On your home LAN, it is easy to send files from one device to another, but when you are away from home, things get trickier. Of course, if you are visiting a friend's home, a USB drive can be a useful tool for transferring files, but what if no one is available to move them? It is not uncommon to have a bunch of media files to share after a trip with family or friends. You can share these on social media (this is what they want you to do). However, there are several reasons you might want to keep them private, so the next question is how to share them without using cloud services.  Email comes to mind, but there are usually limits on the maximum size allowed for messages, and you might overload some recipients' mailboxes to the point where they fail to receive some of the content. And if you are a bit worried about using cloud services, email also involves some Internet servers, too.  Some peer-to-peer file sharing apps exist, but they are typically designed to allow files to ...

AI killed the video star.

Image
In the latest months, I have found myself questioning more and more often the shorts that YouTube is dropping on my feed. The point is not why they are there; the point is whether they are "real". And it is because the pervasive use of AI in video creation is making me now doubt everything I see.  There is an old Arab saying:  "Believe what you see and lay aside what you hear." Whether the origin is right or not, I cannot say( * ).  But what is becoming evident is that the power of the video as "proof" of an event is becoming thinner and thinner every day. After all, Hollywood built an empire on the idea of filming stories, where the premise is to make you believe them. However, we expect news reports to accurately convey real events, not fictional narratives. YouTube, TikTok, and the like are more about keeping us hooked on whatever crap we are interested in. Whether it is a healthy diet, running, fixing your motorbike, woodworking, plumbing, ... you nam...

Dropbox and Antigravity?

Image
I was developing some software and using one folder in my Dropbox. At some point, I wanted to share the results with another person, so I shared that folder with him. After a while, I no longer needed to share that info, so I used Windows Explorer to stop sharing that folder. To my horror, I saw that most of the files in the folder had suddenly disappeared, and an error message appeared on the Dropbox taskbar icon.  As that folder was set to always remain on the hard drive, I did not understand why that was. But even worse, the operation deleted the latest source files from my disk! I panicked and ran to my laptop, disabled the wifi, and recovered the files from the laptop's SSD. Once I felt my code was secure, I returned to my desktop computer. The Dropbox error was a synchronization error, as a file that was opened could not be synchronized. I was viewing an STL file from that folder on MeshLab. Once I closed that app, Dropbox continued to function as normal, and I could see all ...

The art of wasting our time

Image
For a couple of months now, I have been getting calls on my cellphone for a person who is not me. Usually, they are commercial cold calls, but given the influx, I started conversations with some of the people calling me. It turns out they have obtained my phone number from various mobile apps, such as Kaspr , Lusha , or Apollo . No amount of conversation will make up for the time lost. All of them seem to be USA-based companies, but this problem is affecting me in Europe. It won't be easy. The reason is that you cannot talk to an actual human being who gives a shit. By email, they redirect you to their webpage, where you can request that your personal data be removed. But there is a catch: they have messed up merging data from different sources, so your phone number is associated with an identity that is not yours, so you cannot provide all the data they want from you to be able to remove your info from their system, so the calls keep coming in.  I have learned about two different ...

Arduino UNO Q first impressions

Image
I attended a talk by David Cuartielles at the Universitat Politècnica de València, where he discussed bio-degradable PCBs. I was lucky that David gave me one of the new UNO Q boards. I couldn't wait to try this beast out, but I faced some initial trouble.  You can handle the UNO Q board from your computer using either the standalone Arduino App Lab you can download for free, or you can use the Arduino Cloud service on the web. The latter requires you to download the Arduino Cloud Agent, which bridges the Cloud service with USB communication.  The board retains the venerable form factor of the Arduino UNO, although it no longer features a barrel power connector. The board is powered by the USB-C port. Similar to previous boards, such as the Intel Galileo, it features two processors: one handles real-time I/O with an STM32U585, and the other runs Linux Debian with a Qualcomm Dragonwing (QRB2210). A significant amount of power is packed into a compact board. The recommended power...

Backing up your NAS

Image
  Ok, so you have your NAS and you have built it with some redundancy (RAID). But what if the whole thing dies (the system motherboard)? Well, at least you will need a spare unit. Nonetheless, having all your data on a single device that can die anytime does not seem like a good idea, so some sort of backup plan is needed. One possible idea is to have a second NAS unit that will be kept in sync with the main one, so that you can switch it back to be the main one in case of a failure of the main unit. Not cheap but a workable solution. However, certain risks like a robbery or a fire need to be covered, so keeping the two NAS at the same location is not a good idea.  So one possible solution is to have the backup system remote and to connect it to the office system VPN, so backups can take place. This opens up an interesting networking problem if the VPN server is not run by the NAS box, as the VPN addressing space is going to be different than the office network addressing spac...

STL file color information

Image
My first recommendation is not to use that feature, but if it is a bit too late for me, as I did use it in the past. And old code needs some care from time to time. STL files represent triangular 3D meshes, but do not support color in any shape or form. However, some non-standard way of adding color has been used by some companies in the past, and somehow, here we are, using color on STL files.  If you do that, you may wonder what the actual colors are in your STL files, as this feature is quite sketchy for several reasons. So I asked DeepSeek to create me a single-page web app that could help me answer this question locally (without sending your 3D mesh to a web server). Not that the AI was completely willing initially, as it delivered only a shell with fake info, but a bit more persuasion produced a very usable result I am sharing with you here . I decided to write this post instead of placing the AI blog entry (which I created and reviewed, though).  I followed the AI advic...

Just when you least expected it, they will screw you.

Image
 I was using Visual Studio Code with Gemini Code Assist to create a variation of an existing Python script. After a few minutes of back and forth, I got the desired code running. But when I try to run the same script again on the terminal, nothing happens. WTF? Thankfully, I asked Gemini to rebuild the file for me, and a few moments later, I got it back into my VSC editor. However, a minute later, the issue repeats itself.  What good is it to have an IA to write code for you if the file content with the code disappears seconds or minutes later? And it's not that the file disappears, it is just that suddenly the file becomes 0 bytes long. When asked about it, Gemini hinted that, as I was working on a Dropbox folder, it might be a known synchronization issue of Dropbox. Knowing the possible cause of the problem helps, but being a paying customer of Dropbox makes me wonder if I want to keep on supporting them. This is not the first weird issue I have had with them, but other prob...

Part contour simplification, with a twist

Image
 Many vector graphic algorithms have a cost proportional to the number of segments of the shapes involved. Thus, many different polygon simplification algorithms have been developed over the years. The main idea is to represent the original shape, but reduce the total number of edges of the shape's contour.  A favourite of mine is the Douglas-Peucker algorithm. It uses an error parameter that allows the user to tune the acceptable error introduced by the simplification. That works well in many scenarios, but as you may guess, it does not work well for some of my needs. Free form 2D nesting packs groups of parts inside bins, in my case, those bins are rectangles. The rules are that any two parts cannot overlap. Nesting libraries will determine where to place each part inside a bin and what rotation to apply to the part. The number of parts and the number of edges per part have a big influence on the time required to perform the nesting operation. So, being able to simplify the...

One step forward, one step backward

Image
 While it was nice to be able to get a faster 2D nesting code, its efficiency was far from perfect. So, looking at the nesting results, you could see how it could have been done much better in certain cases.  And what we usually do when we overcome a hurdle is to look for the next one. In my case, I realized one of the heuristics of the code was to place small parts inside the unused space of the bounding box of the larger parts. That is ok, but what could be better is to use all the free space of a bin once the first placement of large parts is over.  This time, I leaned on another Chinese AI tool, called GLM-4.5 from the  z.AI company.  I explained the above idea in the chat, and I waited for the magic to happen. I used Roo Code within Visual Studio Code, accessing GLM-4.5 API. A few minutes later, I had a newer version of the library. I was pleasantly surprised when I saw a significant improvement in its packing ability, proving that the new heuristic was a ...

Knocking my socks off!

Image
As I mentioned in my previous entry, I migrated a library from Java to C++ to make it easier to use from Python. I tested its performance on both Linux and OSX, and it was on par with the Java version. Sample file S266.txt would take around 45 seconds on my computer using the Java version, and the C++ version needed thirty-something seconds on a M1 MacBook Pro running OSX, a bit less than that on an i9-13900 server running Linux. From that, I could not claim there was a huge difference in performance compared to the original Java runtime. But I wanted to make a fair comparison, and I wanted to face the trouble of building the library for Windows. It was not a challenge, but it took a while. Let me summarize all the steps I needed to cover: Install Microsoft's Visual Studio (Community Edition) Install Microsoft's vcpkg (C++ package manager) Install CMake. Install dependencies (tbb, gtest, boost, pybind11) Clone the project repository . Build the project. It took me like an hour...

Migrating a Java library to C++ so it can easily be used from Python

Image
Today, we embarked on an ambitious software engineering journey: migrating a sophisticated 2D bin packing program from its original Java implementation into a high-performance C++ library, complete with Python bindings for ease of use. The goal was to retain 100% of the original complex packing logic while unlocking the raw speed of C++. The heart of this migration involved replacing Java's powerful java.awt.geom.Area class. We chose the world-class Boost.Geometry library as its C++ counterpart, meticulously re-implementing every geometric operation, from simple transformations to complex polygon intersections and subtractions. This formed the foundation upon which we rebuilt the original program's advanced packing heuristics. We successfully ported a multi-stage packing strategy, including bounding-box placement, a "drop" simulation for gravity-fed placement, and iterative compression algorithms. However, real-world testing with complex, high-vertex-count polygons r...

From frustration to simplicity

Image
Today, I set out to configure a remote access VPN for my small office. My first choice was L2TP/IPsec with StrongSwan and xl2tpd , mainly because it’s supported natively by Windows. It seemed like a solid option; secure and well-documented. But several hours later, after wading through IKE version mismatches, arcane config options, and ambiguous Windows error codes, I hit a wall. Despite correctly setting up IPsec and L2TP, Windows insisted on trying IKEv2, and StrongSwan repeatedly rejected the connections. Exhausted by endless logs and incompatible defaults, I decided to abandon the legacy stack and try something different: OpenVPN . In under ten minutes, using the widely respected OpenVPN install script by Angristan , I had a working VPN server. The script handled everything—certificates, firewall rules, user config—and generated a ready-to-go .ovpn file. I dropped it into OpenVPN Connect on Windows , hit "Connect", and just like that, it worked . Sometimes the best t...

PyMeshLab: Awesome Power, Quirky Edges – A Gentle Guide for the Adventurous 3D Wrangler

Image
If you’ve worked with 3D meshes in Python, you’ve probably heard the name PyMeshLab . It’s the “Python face” of the legendary open-source MeshLab—famous for its ability to clean up, repair, and process even the messiest 3D models. And truly, PyMeshLab is a fantastic tool : powerful, open, scriptable, and (for most operations) robust. But—let’s be honest—getting started with PyMeshLab sometimes feels a bit like entering a quirky, magical forest: full of treasures, but you might trip on some roots along the way . Here’s my little “cautionary tale” and field guide to the weirdness you may encounter, and how to laugh it off while getting things done. 1. “Is That a Snake or a Camel?!”: The Naming Circus You’ll quickly notice that the naming of filters and methods in PyMeshLab is... creative . Sometimes you call a mesh processing function by a method like compute_normal_for_point_sets() . Other times, the same operation is invoked using apply_filter('compute_normal_for_poin...

Learning Tai Chi with 3D?

 I have recently started learning Chen-style Tai Chi. I like the activity and my instructor, but as I am finding out, it requires more than just a few minutes of practice to improve performance. I have started looking for sources for additional help. Recorded videos are very helpful as they can be a tool for practising at home, but the computer nerd in me wonders if there is a better way.  What I came up with is to create 3D animations in a similar way to a video recording, but with the added benefit that the user could set the point of view of the scene at will. So I started to look around to see how that could be achieved, as my knowledge of the field is second to none.  I learned that motion capture could be used to obtain the motion pattern from a human performer, and that piece of information could be later used to animate a 3D character in a virtual environment. However, the way this is done sometimes requires expensive equipment that may also interfere with the ran...