Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- R = 3.9 #Rotor Radius Centimeters
- E = .075 #Input Shaft Eccentricity Centimeters
- Rr = .4008 #Roller Radius Centimeters
- N = 26 #Number of Rollers
- startRange = 0 # Start of range to be evaluated.
- endRange = 2*math.pi # End of range to be evaluated.
- splinePoints = 25*20 # 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 = (R*math.cos(t))-(Rr*math.cos(t+math.atan(math.sin((1-N)*t)/((R/(E*N))-math.cos((1-N)*t)))))-(E*math.cos(N*t))
- yCoord = (-R*math.sin(t))+(Rr*math.sin(t+math.atan(math.sin((1-N)*t)/((R/(E*N))-math.cos((1-N)*t)))))+(E*math.sin(N*t))
- zCoord = (0)
- 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()))
Advertisement
Add Comment
Please, Sign In to add comment