Need help with Pinion Tooth Profile API

Need help with Pinion Tooth Profile API

Beyondforce
Advisor Advisor
729 Views
4 Replies
Message 1 of 5

Need help with Pinion Tooth Profile API

Beyondforce
Advisor
Advisor

Hey all,

 

I'm new to API scripting and I was hopping someone can help me to translate these 2 X and Y equation to a python script.

 

X equation: 30.3161 * (cos(0.9020 * u) + 0.9020 * u * sin(0.9020 * u))

Y equation: 30.3161 * (sin(0.9020 * u) - 0.9020 * u * cos(0.9020 * u))

 

Umin, Umax, Ustep: 0, 1, 10

 

This script is originally from a Blender tutorial guide, and if someone knows how to do it in Fusion, that will be a huge help.

 

Cheers / Ben.

Ben Korez
Fusion 360 NewbiesPlus
Fusion 360 Hardware Benchmark
| YouTube

0 Likes
Accepted solutions (1)
730 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni
Accepted solution

I believe this script will do what you want.

 

import adsk.core, adsk.fusion, adsk.cam, traceback
import math

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        if app.activeEditObject.objectType != adsk.fusion.Sketch.classType():
            ui.messageBox('A sketch must be active.')
            return
            
        sk = adsk.fusion.Sketch.cast(app.activeEditObject)

        uMin = 0
        uMax = 1
        steps = 10
        
        pnts = adsk.core.ObjectCollection.create()        
        for i in range(10):
            uVal = uMin + ((uMax - uMin) * (i/(steps-1)))
            x = 30.3161 * (math.cos(0.9020 * uVal) + 0.9020 * uVal * math.sin(0.9020 * uVal))
            y = 30.3161 * (math.sin(0.9020 * uVal) - 0.9020 * uVal * math.cos(0.9020 * uVal))
            pnts.add(adsk.core.Point3D.create(x,y,0))

        sk.sketchCurves.sketchFittedSplines.add(pnts)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 5

Beyondforce
Advisor
Advisor

@ekinsb, Thank you very much. It works like a charm!! 🙂

 

Now that I have the Tooth profile and I finish creating the gear, it looks like this (exactly as I want it):

Flat gear.png

 

Now I need to curve all the teeth upwards like this:

Curved gear.png

 

I have a script that should do the trick, but I don't know how to turn it into Fusion pyhtone and to apply it to the above sketch:

	Hide pinion script
import bpy
from math import *

obj=bpy.context.object
mesh=obj.data
for i in range(0, len(mesh.vertices)):
 vert=mesh.vertices[i]
 x=vert.co[0]
 y=vert.co[1]
 z=vert.co[2]
 R=33.037
 alpha=13.702*pi/180
 r=sqrt(x*x+y*y)
 teta=atan2(y, x)
 rnew=R+(r-R)*cos(alpha)
 xnew=rnew*cos(teta)
 ynew=rnew*sin(teta)
 znew=(r-R)*sin(alpha)
 vert.co[0]=xnew
 vert.co[1]=ynew
 vert.co[2]=znew

 

Thank you so much for the help 🙂

 

Cheers / Ben.

Ben Korez
Fusion 360 NewbiesPlus
Fusion 360 Hardware Benchmark
| YouTube

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni

Fusion is creating analytic geometry, both as the sketch geometry and surfaces and solids.  They are not a mesh that can be deformed.  I suspect you can still accomplish what you want but need to look at it differently than you have previously.  It seems like you can extrude your existing sketch and then create another sketch, possibly an arc, that you then revolve around the axis of the gear to remove the material and round the bottom of the gear.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 5

Beyondforce
Advisor
Advisor
I had a feeling you would say that.
Thanks a lot for that help!

Ben.

Ben Korez
Fusion 360 NewbiesPlus
Fusion 360 Hardware Benchmark
| YouTube

0 Likes