Perforate, a Fusion360 plugin

I’m (mostly) done writing my first Fusion360 plugin. Perforate creates random holes in a surface, as long as the edges are all straight lines. It’s available on GitHub. There’s also a GitHub Page with pictures and stuff. Not a lot of stuff, really.

Here are a few things I learned in the process:

The way the algorithm works is by looking at the vertices of the face, picking a random point that sits within these vertices , and then figuring out what the distance is to the closest edge or the closest point. This will dictate how big of a hole can be created there. The problem is that drawing a sketch is done in relative coordinates, regardless of where that sketch sits in space, so first of all, we need to think about the face we’re drawing on in terms of relative coordinates. Hence these lines:

t = sketch.transform

Now t can be used to move vertices from the face, or absolute coordinates, into the face’s plane, which for starts at [0, 0, 0] and lies flat on an xy plane.

v = face.vertices.item(i).geometry.copy()

I also learned (although not implemented yet) that when you get a property of an entity, you can change that property without worrying about  messing with the entity or the properties. Example:

t = sketch.transform
t == sketch.transform # this is False! 


There’s plenty of room for improvements. The obvious would be to have the parameters set by the user through a dialog window. Then there’s a strange bug I need to fix – the program is built to support multiple face selection, but for some reason, the program usually crashes while working on the second surface. Also, the user can accidentally select a sketch rather than a surface, and in that case, I should have the program select the corresponding surface. The hardest part will be to support surfaces that have curved edges.

Anyway, I made this:

2 thoughts on “Perforate, a Fusion360 plugin”

Leave a Reply

Your email address will not be published. Required fields are marked *