Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with add-in for cutting finger joints

Message 1 of 8
700 Views, 7 Replies

Help with add-in for cutting finger joints

Hi everyone,

I'm new to Fusion (started 2 days ago) and enjoy the idea of designing in a parametrized way. As I come from a programming background, I thought, I'd try writing an add-in as a way of getting to know Fusion. I'm starting to get a grip on the API and managed to create a new command to perform some of the steps below but I still have conceptual problems in making the add-in work in a parametrized setting.


I would like to share my plan for this and the problems I ran into so far. I hope some of you can help me with this or have useful constructive feedback. My goal is to implement a tool that takes two overlapping bodies and an axis and cuts finger joints perpendicular to the axis into the bodies to resolve the overlap. I have seen a very useful video about finger joints but I would like to make this a bit more general where it can work on any two overlapping bodies. This is how I imagine this operating:

Step 1: The user selects two overlapping parts and an axis. (I forgot the axis in the screenshot, it should be z axis.) She also enters values for finger width and distance (or alternatively the number of fingers).


Step 2: We create new bodies from the intersection of the bodies.


Step 3: We create a plane along the axis and through some arbitrary point. The choice does not matter as long as it is not on the line itself (because then the plane is underdefined), so we could use the first base vector that is not along the line.


Step 4: We create a sketch on that plane and project in the bounding box of all the bodies created in step 2. This step already shows the two main problems that I am having:

  • (Problem A) How can we select all bodies of a component or all profiles in a sketch in a parametrized way, so that if the number of created bodies changes in the previous step, we still use all bodies?
  • (Problem B) How can we access the bounding box of a component or a body and project it to a plane?
    Since I do not know how to solve these, the screenshot uses the projection of the body instead of its bounding box.


Step 5: We create a rectangle on the sketch from step 4 that goes all the way across the part, so its left and right side are colinear with the edges of the bounding box (which I do not have, see Problem B). The height of the rectangle is the user input for the finger width and the location can also be computed from the size of the bounding box and the user input. We then use a rectangular pattern to replicate the rectangle once for each finger. The number and distance of fingers can again be derived from the size of the bounding box and the user input.


Step 6: We now have rectangular profiles where the fingers should be. In my case, since I projected the whole body instead of the bounding box, I had a lot of additional profiles in the sketch that result from intersections of the projected lines with the rectangles. I only want the profiles of the rectangles I created and I want to select all of them in a parametrized way (see problem A above).


Step 7: We can use extend to cut the profiles out of the bodies created in step 2. For this step, I thought the settings "direction = two sides" and "extend = all" for both sides would do what I want, but in the example, setting "extend = all" kept the extend at 0. This would also be no problem, if we had the projection of the bounding box onto the plane perpendicular to the selected axis (xy in this case). But this again is problem B.


Step 8: Now we select all bodies that result from step 7 (doing this in a way that works when the input changes is problem A again). We then use them to cut the fingers out of one input part.


Step 9: With one part ready, we can simply use it to cut the fingers into the other part.


Step 10: Finally, we can clean up by removing the temporary component and the sketches that were created on the way.




So to me it looks like my main problems are projecting a bounding box into a plane and selecting all objects that resulted from a previous operation in a parametrized way. Of course it could be that one or both of these problems is not solvable. In this case, I'd like to hear your thoughts about how to approach this problem.

Message 2 of 8

Well you certainly picked a complicated one to start your journey with!!


How did you get on?


Have you considered scripting a loop in the solid environment (staying out of sketch entirely) ?


This all sounds very interesting.  If you're considering doing an add-in for it, remember to give the user an option for tolerance, so they can have loose or tight fitting fingers... and perhaps even a dovetail option, if they want triangles...

Message 3 of 8

I managed to get a non-parametric version of the add-in running. It works a bit differently from what I described above, more in line with what you suggested. I like the idea of adding a tolerance. The current add-in doesn't support this yet but it would be easy to add. Dovetail joints are more complicated with the current approach because I didn't make the assumption that the joined pieces have a specific shape or overlap only once.


My main problem (and the reason I kept this thread open) is to turn this into a parametric version, so that you could afterwards change the size of the pieces and the position and size of the joints would update as well. Do you have a suggestion of how to achieve this?


Message 4 of 8

Wow - your add-in looks super-schmick so far!!


Amusing that we might both be stuck on the same problem?  Here's my posting on a similar issue:


My problem is that I cannot transplant the math needed to make my solution directly into the design, since it requires extreme math an a huge database to select the required shape.


Your solution seems on the surface that it might be possible to solve by inserting the result of your add-in as a parametric solution itself?


For example - I manually created a ball-bearing (including shell, hub, race, and balls) where every bit was a parameter (number of balls, tolerance, sizes, spacing, etc).  Or another example - I created a multi-use hub (for propellers or an anemometer or a wheel) where the number of spokes/arms/blades is a parameter, and other parameters define wall thickness and tolerances etc.  My point is that the sketch itself does not have dimensions - it uses variables for *everything* - so when stuff changes, it all just self-updates and keeps working.


MAYBE that's possible for you?  Your add-in does the calculations it needs, but instead of doing the work, it outputs all the parameters and formulas needed into variables, and then the "work" gets done by the "thing" you create being based on those parameters (e.g. number of slits, sizes, etc).


Or another way to think of the same thing: imagine you had to do this every day, for different things, and Fusion had no API or programming, only parameters.  Your "program" you would write is not in python, it's in mathematical relationships and variables instead.  So - your add-in simply needs to output those mathematical relationships.  A "program" that outputs another "program", if you will?

Message 5 of 8

Thanks. I think most of my computations could be written inside parameters. I'm not quite sure if it possible to access the bounding box of an object in the way I would need but that may be possible with a bit more research. I didn't look into this further because I see no way to solve a different problem and without a solution to the second problem a solution to first wouldn't help me. The one that I got stuck on was how to access all bodies that result from a cut. I'll explain what I mean:

My current workflow is as follows:

  1. Generate the intersection of the two bodies
  2. Generate a tool body (slices overlapping the tool body, see step 7 above)
  3. Use the tool body to cut the intersection into separate bodies (the fingers)
  4. Cut the fingers out of the original bodies

I can imagine that I might be able to do everything up to step 3 in the way you suggested (although I'm not sure about some steps) but then the result of step 3 are several independent bodies. If I use a CombineFeature for step 4, I can feed it a selection of bodies to use as cutting tools. When the add-in runs, I can select all bodies that are generated in the step above. But as far as I know, this selection is stored by storing the IDs of all selected bodies, so if there are 4 tool bodies while the add-in runs, the stored selection consists of 4 IDs. If I later change parameters so there are now 5 tool bodies, the list will still have those 4 IDs and only cut 4 of the 5 fingers.


As far as I can tell, this is a general limitation of the Fusion API. Custom add-ins are just not as powerful as built-in commands. I saw a related suggestion in the ideastation but it would need a lot more votes before it becomes visible

Message 6 of 8

Thinking outside the box for a moment... it seems superficially possible to have a "re-calc" option within your add-in... I know it's not "true" parametric, but, after the user changes something, if they then click "re-calc", you could use settings you've pre-saved in the sketch to "un do" then "re do" (or update) the stuff from you earlier add-in's invocation.  Maybe?


I'm going to mess with this idea more tonight - if I hit any show-stoppers, I'll let you know.


Thanks for the help earlier too, btw.  Very useful!


Also - I notice Fusion 360 is a "moving target" - anything it doesn't do/support now, could well spring into existence soon.

Message 7 of 8

Yes, that could be an option. It's not ideal for people using the feature a lot because they would have to go through and fix every use of the add-in individually. I also don't know how to trigger this. Is there a way to hook into the context menu when you click on something in the timeline? The final problem would be to have a clear association of stored values to timeline entries (i.e., if there are three uses of the add-in and three sets of parameters, which one is which?) Let me know if you find out anything about this in your tests.

Message 8 of 8
in reply to: OceanHydroAU

I swear there must be a programming spirit watching over me on this stuff... while hunting for how to dimension things from the API, I found this:-


which leads to this:-


which is a working example of how an add-in can watch for changes to stuff.


(It's actually a slightly longer story - I started off here: which gave me the idea to do this:-


[cnd@mac Autodesk Fusion 360]$ pwd
/Users/cnd/Library/Application Support/Autodesk/Autodesk Fusion 360
[cnd@mac Autodesk Fusion 360]$ grep -r insertedFromURL .


which lead me to this:-


[cnd@mac Autodesk Fusion 360]$ vi ./API/Python/defs/adsk/


wherein I searched for /event/ which revealed ApplicationCommandEvent which I used to discover the aforementioned links in the forums...


Now... time to climb out of this half-shaven field of yaks and get back to my dimension quest.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report