You are browsing as a guest. Sign up (or log in) to start making projects!

Voronoi Converter for Autodesk Fusion

  • 10 Devlogs
  • 28 Total hours

A fusion script that takes a body and transforms it into a 3D voronoi structure

Open comments for this post

5h 28m 7s logged

Devlog 10 - Fusion Voronoi Script

Working on a v2 for the script, I did some optimization to run the script faster, one thing that I changed for that purpose is that I was creating every connection extrude in a different operation, now I’m doing it all in a singly operation.

I’m also trying to expand the functionality to 2D, the first challenge I faced while doing so is that I wanted to create 2 tabs for it, one for 3D and one for 2D but then I discovered that fusion don’t let you know which tab it was before the user clicked ok (And I needed this to decide which operation to run), so, I needed to add a listener that fires when the user changes tabs, and discover what, fusion also doesn’t tell me which tab he changed to, so, I need to just flip between the two when an event is fired.

To be honest, something I really didn’t expect is happening, the 2D is turning out to be harder than the 3D, I’m having some really bad problems with the offset, its really restrictive so for example, if I trimmed an edge and now there is a point in the middle of one other edge, it’s going to raise an error, if it’s not a convex shape (has some angle that’s bigger than 90), it’s going to raise an error, and I took a really long time to figure that it was that restrictive, so, I’m seriously considering adding my own offset function, I even tried to use an external library called shapely but that also wouldn’t work with rounded edges, just straight ones.

That’s how my menu is looking right now, as you can see I got 2 tabs!

0
0
52
Ship #1

I built a script that converts bodies in fusion to 3D voronoi patterns!
I think that the most challenging part for me was connecting SciPy’s voronoi tools with fusion’s api.
You can check out a result of my project below or you can download it and try it yourself at github!

  • 9 devlogs
  • 23h
  • 16.32x multiplier
  • 374 Stardust
Try project → See source code →
Open comments for this post

1h 57m 27s logged

Devlog 9 - Fusion Voronoi Script

I was still getting some bugs with the combine, now, it was creating some weird really small sections of pipes, I spent some good time researching and thinking that it was some internal kernel problem but in reality it was just because to check if 2 bodies intersect I was doing (If intersection.volume > 0.00001), and those bodies were really small, so I just changed it to bigger than 0 and it solved the problem.

I think I’m pretty much done for version 1.0, below is a before and after applying my script.

0
0
5
Open comments for this post

2h 40m 40s logged

Devlog 8 - Fusion Voronoi Script

Implemented Poisson disk sampling for random number generator and LLoyd’s relaxation to get seeds that are more evenly spaced.
Also I was getting some internal errors in the combine features, so, I saw it in some old forums that combining a lot of bodies in a single feature could cause some problems like that, so I changed it tocombine the bodies 1 by 1.
Some alterations on fusion’s manifest too, added version and description, getting ready for first ship!

0
0
9
Open comments for this post

1h 25m 33s logged

Devlog 7 - Fusion Voronoi Script

Just spent around 2 hours researching and trying to connect scipy and fusion to create each cell as a separate body and then intersect them with the original body to get the centroid. In the end I couldn’t get it to work, below is an image of my best attempt 😭😭

0
0
62
Open comments for this post

2h 16m 35s logged

Devlog 6 - Fusion Voronoi Script

Today I first started thinking about how i would implement lloyd’s relaxation into my code (It’s an algorithm that moves every seed of the voronoi to its center of mass, which makes the cells more similar in volume to each other) but I quickly faced a big problem, sometimes my voronoi cells goes partly off the original body, which would mess up with the relaxation and could move the seeds out of the original body, what would cause me bugs, I tried some different methods using scipy’s ConvexHulls but I wasn’t able to create the cells just by using the points such as the voronoi algorithm does.

So, I started working on another problem that actually helped me solve the first one! The weird connections on the faces, to solve it I improved the way I was generating ghost points (some voronoi seeds that are put outside the body to restrain the pattern but are not extruded afterwards), at first I was generating them 50% evenly spaced along each face and the other 50% randomically inside a margin around the body, now I am mirroring each seed across each face and using the mirrored points as the ghost points, since both of them are the same distance from the surface, they create beautiful boundaries, it works perfectly with flat faces but still gets kind of messy sometimes with the rounded ones.

I faced some problems while doing it, at first, I was just mirroring them against the bounding box of the body, what made it easier and looked great for simple shapes like cubes, but, the rounded edges were not taken in account and if the faces were not parallel to the unit vectors they didn’t look good, since the bounding box is always parallel to them. To solve that I tried iterating through each face, getting the minimum distance point between the face and the seed and then mirroring it through that point, at first it looked really bad, as if I didn’t even had the ghost points, I tried the other method again and at the end came back to the minimum distance method again just to realize that the first time I was getting the minimun distance point at the seed instead of the point at the surface 😅. Even though it looked better for the faces not parallel with the main axis, it still look weird sometimes on the rounded faces.

Some pics of how it’s looking right now, you can see at the second one that some of the edges on the rounded surfaces are still getting clipped sometimes

0
0
6
Open comments for this post

3h 15m 37s logged

Devlog 5 - Fusion Voronoi Script

I fixed the loose ends! Today I tried some different methods, first I got all the points where the voronoi connections intersected with the surface of the object, the intersection point, then, I built connections between the point and a random edge of the face it’s in.
Doing it randomically looked a little bit too messy, so, I changed to code for it to connect to closest edge on the face.
I still think it could improve, the straight edges take away the voronoi look so I’m still thinking of a better solution for this problem.
Some struggles I had today, so, for the first time I tried running the script in an open box shape and got an error because they didn’t touch and my code tried to connect them, to fix it, I moved all the join features to the end of the code where all the bodies are touching, but I’m still getting some of those combine errors now and then, I’m not sure why since all the bodies touch eachother.

0
0
8
Open comments for this post

4h 5m 17s logged

Devlog 4 - Fusion Voronoi Script

If you don’t know about my project yet, let me give you a quick summary!
So, I’m building a script for fusion360 that transforms solids it into Voronoi patterns, what’s a Voronoi pattern you may ask, so imagine you have some random point inside a shape, each point “claims” the space thats closer to it than to the other points, the boundaries of those areas form the Voronoi pattern! And that ends up looking natural and pretty cool to be honest

So, today I finally started creating some Voronoi pattern!!
That’s one of the parts that was not much harder than I expected to be honest, I needed to refactor some of the code like the one to sweep the edges for it to be able to create edges just using 2 points instead of a body edge, I needed to do this because before I was just using that function to create the wireframe using the body edges, but know I needed to create the connections for the Voronoi pattern and I just had their initial and final point. Also, I will need to refactor that code again soon and change the sweep feature for a pipe feature because its causing some serious performance issues with the code.

The Voronoi is generating well, the ghost points work and restrain it so it doesn’t go to infinity but it still goes a little off the boundaries, and that’s expected, so, I intersect the original body with the Voronoi pattern and then combine it with the wireframe to create the final body, but, as you can see in the images below it creates some weird cuts on the surfaces that honestly, look bad, that’s not how I want my final product to look like.

To solve it, I thought about getting every point where the edges of the Voronoi intersects the surface of the body and then create a connection between that point and a randomly selected edge on the same face that it intersects. Hopefully this will make the pattern look more natural, I’m still working on it tought.

0
0
6
Open comments for this post

3h 4m 38s logged

Devlog 3 - Fusion Voronoi Script

If you don’t know about my project yet, let me give you a quick summary!
So, I’m building a script for fusion360 that transforms solids it into voronoi patterns, what’s a voronoi pattern you may ask, so imagine you have some random point inside a shape, each point “claims” the space thats closer to it than to the other points, the boundaries of those areas form the voronoi pattern! And that ends up looking natural and pretty cool to be honest

Today I finally started the actual voronoi logic!!

So, I made some important scripts today, one to generate the random seeds inside the solid, started working on a script that generates the voronoi patterns and return the edges so that I can sweep them and create the connections in the body, but I quickly faced a problem, voronoi patterns go to infinity.

I brainstormed a little bit until I got to a solution, ghost points, so, for them to work, I generate some random points around the solid (I’m using a margin that’s 10% bigger than the bounding box of the solid) and then use those points to create the voronoi but don’t build connections between 2 ghost points. The purpose of them is to stop the infinite boundaries by creating a “barrier” around the solid.

To give it some “uniform” density, I decided to do half points equally spaced around the solid and the other half generated randomically, below you can take a look at the result!

First Image: Random seeds inside the solid
Second Image: Ghost points (all points are outside the box even tought its hard to see it from a single angle)

0
0
22
Open comments for this post

3h 14m logged

Devlog 2 - Fusion Voronoi Script

Big improvements here! Today I thought a lot about how I’m going to do this project and realized that on top of making the voronoi pattern, it would also be very important to mantain the original shape/boundaries, so, I decided to convert body into a wireframe and use it’s vertices as seeds for the voronoi.

I started thinking about how I would go about the rounded edges, and to be honest, I took longer than what I’d like to admit for me to realize that I could just sweep a circle through its edges, for some reason I thought that the rounded edges didn’t count as edges in the API 😅

To connect it all, I revolved spheres using the same radius as the edges in the vertices (this radius can be inputted by the user), another problem I faced was that after combining I wanted to intersect the new wireframe with the original body to cut any excess over the original volume, but for some reason that also took me a good time, when I put the original body as the target body it didn’t work, I needed to use it as the tool body and the wireframe as the target.
Also I organized most of the code, separating it in modules for easier reuse.

4
0
47
Open comments for this post

57m 8s logged

Devlog 1 - Fusion Voronoi Script

Hello everyone! This is my first devlog and first project here in stardance, I’m coding a script for fusion 360 that is going to take a body and convert it to a voronoi pattern.

To be honest, I’ve never coded any fusion script, so, today was mostly used for me to learn the basics and get familiar with the API, for this, I built a simple UI that creates a box from the dimensions inputted by the user, with this, I was able to learn about the API architecture, such as how the handlers and hierarchy works.

Not a big achievement yet, but I believe that building a strong foundation is really important on a project like this. Looking forward to sharing more of my progress soon!

Video Showcase

0
0
9

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…