I’ve created a building block for 3D printing called PrintABlok. So far I’ve done all my modeling in Blender (of course). PrintABlok is (largely) a system that can be built on to make interconnecting projects. So far I’ve built quite a library of parts and used it to build an array of projects from functional to fantastic including board games and articulated model kits.
Lately I’ve been focused on making it easier to make customized base bloks as a jumping off point for various projects. In this process I ran into a bit of a bit of a roadblok. So I started looking into scripting to fix it.
But in the process I started to wonder, why not just make an add-on that can add PrintABlok objects just like you would any other kind of object?
Theoretically I have the skills to do this myself. I know my way around code generally. Though I am rusty and I’ve never developed a Blender Add-on. Ideally this inspires some more experienced developer to want to take a shot at it. But I’m not holding my breath. (Though, as a moderately successful youtuber I might be able to throw some funds at this.)
Ideally, the add-on I would like to develop would allow anyone to add:
Basic Bloks - Customize X/Y/Z dimensions and connectors on top, sides, or bottom, and in between connectors on each.
Half Blok - Customize X/Y, and whether connectors are on the top and bottom and whether there’s in between connectors as well.
Panel - Customize X/Y, and whether there’s inbetween connectors
Are there any code examples or tutorials I could learn from that would give me an idea of where to start both making a plugin and generating objects like this?
Interesting idea, I take it the PrintABlok are 3d printed?
So there’s 2 ways to do this - python scripting or geometry nodes.
For python, open a text editor and look at Templates → Python → Operator Mesh Add. That will give you a script in the text editor that can create a box (cube). Run the script by hitting the Play button in the header, then in the 3d view do a Shift-A → Mesh → Add Box and you will add a Box (cube) to the scene.
Doing this in python requires you to define every vertex for your part (x,y,z location of each vert) and then define the faces, which is just what verts make up the face. The beginning of that script, the def add_box(width, height, depth): shows how that is done.
You’d have to break everything down into it’s most simplest part, like a 1x1 part, then to make a 6x4 part, you’d just repeat (loop) the code 6times x 4times
Really not that hard to do in python, if you know python. If you only theoretically know how to do this, then it will be a steep learing curve.
Think you need to be looking at geometry nodes for this. Doesn’t require progamming skills, but you have to learn how they work. When I started learning geo-nodes I came across a youtube about creating legos using geo-nodes.
I’m not very good at geo-nodes, but I think that is where you want to be looking.
Appreciate it. Good to know where to find that code. I didn’t know that before.
I just want to mention that I’ve explored geo nodes and, while they might be able to do the job, they don’t have much advantage over how I’m doing it. The biggest thing that my current system can’t do is automatically name the resultant mesh based on the X/Y/Z size of the object. Neither can GeoNodes. So it’d be a lot of work to do pretty much what I’m doing already (if a little clumsier).