Created
June 27, 2018 11:13
-
-
Save macaba/f957d89c147cccccf12a155013066906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import adsk.core, adsk.fusion, adsk.cam, traceback, math | |
def run(context): | |
ui = None | |
try: | |
app = adsk.core.Application.get() | |
ui = app.userInterface | |
#ui.messageBox('Hello script') | |
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) | |
# Create an object collection for the points. | |
points = adsk.core.ObjectCollection.create() | |
Dia = 6.6 #Diameter of the pin circle | |
R = Dia/2 # Radius of the toro | |
E = 0.1 # Eccentricity of input shaft | |
Rr = 0.2 # Radius of the rollers | |
N = 19 # Number of rollers | |
l = 2*math.pi | |
i = 0 | |
splinePoints = (N-1)*20 | |
while i <= splinePoints: | |
t = (l/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)) | |
points.add(adsk.core.Point3D.create(xCoord,yCoord,0)) | |
i = i + 1 | |
sketch.sketchCurves.sketchFittedSplines.add(points) | |
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