Skip to content

Instantly share code, notes, and snippets.

@d0n13
Created June 20, 2024 10:30
Show Gist options
  • Save d0n13/59bb8bd8ef68e762824bcad8e1098fb4 to your computer and use it in GitHub Desktop.
Save d0n13/59bb8bd8ef68e762824bcad8e1098fb4 to your computer and use it in GitHub Desktop.
CNC-Clamp with Logarithmic spiral for Fusion 360
{
"autodeskProduct": "Fusion",
"type": "script",
"author": "Donie",
"description": {
"": "Create a cam shape for clamp"
},
"supportedOS": "windows|mac",
"editEnabled": true
}
#Author - Donie Kelly
#Description - This script creates a spiral path for the clamp using a Logarithmic spiral equation.
import math
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
rootComp = design.rootComponent
sketches = rootComp.sketches
sketch = sketches.add(rootComp.xYConstructionPlane)
sketch.name = 'Clamp'
lines = sketch.sketchCurves.sketchLines
start = adsk.core.Point3D.create(0, 0, 0)
points = adsk.core.ObjectCollection.create()
a = 3.2
b = 0.2
# Draw a spiral
for i in range(30, 340, 5):
t = math.radians(i)
x = a*math.exp(b*t)*math.cos(t)
y = a*math.exp(b*t)*math.sin(t)
points.add(adsk.core.Point3D.create(x, y, 0))
# Create the spline.
spline = sketch.sketchCurves.sketchFittedSplines.add(points)
spline.isFixed = True
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