Skip to content

Commit

Permalink
First source code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Kildall committed Mar 30, 2015
1 parent 56e12ac commit 3f31386
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
@@ -0,0 +1,10 @@
#########################
# Python patterns
#########################

# Compiled Python scripts
*.pyc
*.py~

# OSX
.DS_Store
9 changes: 9 additions & 0 deletions FJBox/FJBox.manifest
@@ -0,0 +1,9 @@
{
"autodeskProduct": "Fusion360",
"type": "script",
"author": "",
"description": {
"": ""
},
"supportedOS": "windows|mac"
}
105 changes: 105 additions & 0 deletions FJBox/FJBox.py
@@ -0,0 +1,105 @@
#Author-Scott Kildall
#Description-Finger Joint Box for Fusion 360

import adsk.core, adsk.fusion

# width = x
# depth = z
# height = z
def buildBox(rootComp,w,h,d,th):
sketch = addXYPlane(rootComp)
buildSide(rootComp,sketch,w,h,-d/2,th)
buildSide(rootComp,sketch,w,h,d/2,th)

sketch = addYZPlane(rootComp)
buildSide(rootComp,sketch,d,h,-w/2,th)
buildSide(rootComp,sketch,d,h,w/2,th)

sketch = addXZPlane(rootComp)
buildSide(rootComp,sketch,w,d,-h/2,th)
buildSide(rootComp,sketch,w,d,h/2,th)

# gets the XY plane and adds it to sketch, so we can generalize the profile-building
def addXYPlane(rootComp):
sketches = rootComp.sketches
xyPlane = rootComp.xYConstructionPlane
sketch = sketches.add(xyPlane)
return sketch

# gets the XY plane and adds it to sketch, so we can generalize the profile-building
def addYZPlane(rootComp):
sketches = rootComp.sketches
yzPlane = rootComp.yZConstructionPlane
sketch = sketches.add(yzPlane)
return sketch

# gets the XY plane and adds it to sketch, so we can generalize the profile-building
def addXZPlane(rootComp):
sketches = rootComp.sketches
xzPlane = rootComp.xZConstructionPlane
sketch = sketches.add(xzPlane)
return sketch


#def buildSide(rootComp, sketch, sideStr, x,y,z,th):
def buildSide(rootComp, sketch, px, py, offset,th):
try:
# Draw two connected lines.
lines = sketch.sketchCurves.sketchLines;
lineArr = []
lineArr.append(lines.addByTwoPoints(adsk.core.Point3D.create(-px/2, -py/2, offset), adsk.core.Point3D.create(px/2, -py/2, offset)))
lineArr.append(lines.addByTwoPoints(lineArr[0].endSketchPoint, adsk.core.Point3D.create(px/2, py/2, offset)))
lineArr.append(lines.addByTwoPoints(lineArr[1].endSketchPoint, adsk.core.Point3D.create(-px/2, py/2, offset)))
lineArr.append(lines.addByTwoPoints(lineArr[2].endSketchPoint, adsk.core.Point3D.create(-px/2, -py/2, offset)))
extrudeSketch(rootComp,sketch,th)

except Exception as error:
getUI().messageBox('Failed : ' + str(error))


def extrudeSketch(rootComp,sketch,th):
# Get the profile defined by item#0.
prof = sketch.profiles.item(0)

# Create an extrusion input to be able to define the input needed for an extrusion
# while specifying the profile and that a new component is to be created
extrudes = rootComp.features.extrudeFeatures
extInput = extrudes.createInput(prof, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)

# Define that the extent of the thickness
distance = adsk.core.ValueInput.createByReal(th)
extInput.setDistanceExtent(False, distance)

# Create the extrusion.
ext = extrudes.add(extInput)

def getUI():
app = adsk.core.Application.get()
ui = app.userInterface
return ui

def main():
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface

design = app.activeProduct
if not design:
ui.messageBox('No active Fusion design', 'No Design')
return

# Get the root component of the active design.
rootComp = design.rootComponent

# get input from user here
w = 12 # x = 120mm
h = 6 # y = 60mm
d = 3 # z = 30mnm
th = .1
buildBox(rootComp, w,h,d,th)
except Exception as error:
ui.messageBox('Failed : ' + str(error))


main()

0 comments on commit 3f31386

Please sign in to comment.