Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fusion 360 equation driven curve API example
# For more details see: https://capolight.wordpress.com/2018/07/02/how-to-sketch-equation-curves-in-fusion-360/
import adsk.core, adsk.fusion, adsk.cam, traceback, math
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# Get the root component of the active design.
rootComp = design.rootComponent
# Create a new sketch on the xy plane.
sketches = rootComp.sketches
xyPlane = rootComp.xYConstructionPlane
sketch = sketches.add(xyPlane)
points = adsk.core.ObjectCollection.create() # Create an object collection for the points.
# Enter variables here. E.g. E = 50
startRange = 0 # Start of range to be evaluated.
endRange = 2*math.pi # End of range to be evaluated.
splinePoints = 100 # Number of points that splines are generated.
# WARMING: Using more than a few hundred points may cause your system to hang.
i = 0
while i <= splinePoints:
t = startRange + ((endRange - startRange)/splinePoints)*i
xCoord = (math.sin(2*t))
yCoord = (math.sin(3*t))
zCoord = (2**t)
points.add(adsk.core.Point3D.create(xCoord,yCoord,zCoord))
i = i + 1
#Generates the spline curve
sketch.sketchCurves.sketchFittedSplines.add(points)
# Error handeling
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.