How to draw an Archimedean spiral using Python

How to draw an Archimedean spiral using Python

Anonymous
Not applicable
5,683 Views
4 Replies
Message 1 of 5

How to draw an Archimedean spiral using Python

Anonymous
Not applicable

How would one draw an Archimedean spiral using Python code? I've been trying to draw one using arcs with the 

addByCenterStartSweep() method. Also tried using Ellipses but nothing has worked.

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

marshaltu
Autodesk
Autodesk

Hello,

 

I am not sure if you have tried to draw an archimedean spiral by UI in Fusion 360. If it worked for you, we can probably draw it using Python API. If so, please share which commands you use to do that in UI? Otherwise it would be a limitation of Fusion 360 and we have to add the functionality before it is exposed by API. Please log you request to our idea station.

 

https://forums.autodesk.com/t5/fusion-360-ideastation-request-a/idb-p/125

 

Thanks,

Marshal 



Marshal Tu
Fusion Developer
>
0 Likes
Message 3 of 5

Anonymous
Not applicable

I couldn't find anything using the UI. I tried using sketch arcs on the UI but could not create an archimedean spiral.

This is the best I could do on my own, using my own script I made using arcs. It could just be that I'm not using the correct formula for drawing spirals.

Below is the code I use to make the spiral sketch seen below.

Spiral.jpg

 

 

 

 

 

 

def MakeSpiral(Wirediameter):

app = adsk.core.Application.get()

ui = app.userInterface

product = app.activeProduct

design = adsk.fusion.Design.cast(product)

rootComp = design.rootComponent

sketches = rootComp.sketches

sketch1 = sketches.add(rootComp.xZConstructionPlane)

sketchLines = sketch1.sketchCurves.sketchArcs

StartPoint = adsk.core.Point3D.create(-(Wirediameter+2.0), 0, 5)

degrees = 350

n = 0

while(Wirediameter > .1 and degrees > 0):

if(n == 0):

x = StartPoint.x

y = StartPoint.y

z = StartPoint.z

middle = (x+Wirediameter)/2

middle2 = (y-Wirediameter)/2

CenterPoint = adsk.core.Point3D.create(middle, middle2, z)

SweepAngle = degrees * (3.14 / 180)

arc = sketchLines.addByCenterStartSweep(CenterPoint, StartPoint, SweepAngle)

Wirediameter = Wirediameter - .1

degrees = degrees

StartPoint = arc.endSketchPoint

n = n + 1

else:

x = StartPoint.geometry.x

y = StartPoint.geometry.y

z = StartPoint.geometry.z

middle = (x+Wirediameter)/2

middle2 = (y-Wirediameter)/2

CenterPoint = adsk.core.Point3D.create(middle, middle2, z)

SweepAngle = degrees * (3.14 / 180)

arc = sketchLines.addByCenterStartSweep(CenterPoint, StartPoint, SweepAngle)

Wirediameter = Wirediameter - .2

degrees = degrees

StartPoint = arc.endSketchPoint

n = n + 1

0 Likes
Message 4 of 5

marshaltu
Autodesk
Autodesk

Hello,

 

I am aware you have created a request in our idea station. Thank you. I also searched and found an user did similar thing to you. Maybe you can borrow the idea. 

 

https://forums.autodesk.com/t5/fusion-360-design-validate/i-am-trying-to-make-a-scroll-shaped-part/m...

 

Thanks,

Marshal



Marshal Tu
Fusion Developer
>
0 Likes
Message 5 of 5

BrianEkins
Mentor
Mentor
Accepted solution

I've just created a blog post that will hopefully answer your question.

 

https://ekinssolutions.com/creating-equation-curves-in-fusion-360/

 

Spiral.png

 

 

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com