Transfering Math (Trig functions) to Fusion 360.

Transfering Math (Trig functions) to Fusion 360.

Anonymous
Not applicable
2,751 Views
2 Replies
Message 1 of 3

Transfering Math (Trig functions) to Fusion 360.

Anonymous
Not applicable

Hello,

Will you show me how to convert (from paper) trig functions (epicycloid curve and hypocycloid curve) into Fusion 360?  Thank you.

0 Likes
Accepted solutions (1)
2,752 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni
Accepted solution

Fusion doesn't currently support the ability to create a curve given an equation.  However, using the API you can draw a curve that approximates an equation.  The Python code below is a simple example.  Basically, you code your equation in Python and use it to calculate points along the curve defined by your equation.  You can then create a spline in Fusion that fits through the points.  In your case you mentioned epicycloid hypocycloid curves.  You would do the same thing but you would also want to break the calculation up so each lobe is calculated seperately and created as a single spline.  If you tried to create them all as a single spline it would smooth out the cusps.

 

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

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        des = app.activeProduct
        root = des.rootComponent
        sketch = root.sketches.add(root.xYConstructionPlane)
        
        pnts = adsk.core.ObjectCollection.create()
        lowX = -3
        highX = 3
        num = 20
        for val in range(0,num):                
            x = ((highX - lowX) * (val/(num-1))) + lowX
            y = x * x + 3
            pnts.add(adsk.core.Point3D.create(x,y,0))
            
        sketch.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 3

Anonymous
Not applicable

Thank you, Brian for taking time to answer my inquiry.  You did a fantastic job not only explaining it well, but also in a courteous and class way.  

Best to you,

Tom

0 Likes