Guitar Creation Add-in [WIP] - Help desired!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey everyone!
I'm just as new to Fusion 360 as I am "writing" python code. My 3D background is in film/game oriented creation so CAD is a much different approach and I'm doing my best do adjust!
Ideally I'd love to create an add-in which would be very similar in nature to the Bolt and Spur Gear add-ins already provided as samples. Its purpose would be to construct the 'core' of the guitar based on user inputted parameters in a GUI. I have an incredible amount of questions, but am trying my best to figure as much out on my own as I can. I'm not terribly sure where to start in defining my goals, and I fear I'd just become a rambling fool... Here's what I have so far!
import adsk.core, adsk.fusion, traceback, math from math import sqrt #xN = Width at nut
#xB = Width at end #yN = Radius
#yB = Radius at end #L = Length of fretboard xN = 1.75 yN = 10 xB = 2 yB = 16 L = 18.75*2.54 aN = yN-sqrt((yN**2-(xN/2)**2)) aB = yB-sqrt((yB**2-(xB/2)**2)) firstPtN = adsk.core.Point3D.create((xN/-2)*2.54, 0, -L) secondPtN = adsk.core.Point3D.create((xN/2)*2.54, 0, -L) centerPtN = adsk.core.Point3D.create(0, aN*2.54, -L) firstPtB = adsk.core.Point3D.create((xB/-2)*2.54, 0, 0) secondPtB = adsk.core.Point3D.create((xB/2)*2.54, 0, 0) centerPtB = adsk.core.Point3D.create(0, aB*2.54, 0) 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) # Create fretboard arcs sketchArcs = sketch.sketchCurves.sketchArcs arc1 = sketchArcs.addByThreePoints(firstPtN, centerPtN, secondPtN) arc2 = sketchArcs.addByThreePoints(firstPtB, centerPtB, secondPtB) except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Most of this has been butchered and chopped from the other samples. It works, but it sure isn't pretty or orthodox. Basically my first objective is to be able to create a fretboard based on user input. So far I was able to figure out how to create 3-point arcs for proper fretboard radii and establish the length. The next step would be to loft the two curves together, and I've found I can only do that in Patch mode, and haven't a clue how to write that in python.
Again I'm pretty poor at writing code/script so please bare with me and my amateur attempts, but I have to start somewhere!
I guess my initial questions are:
- How do I clean up the code to make it more orthodox?
- Am I able to set the units to inches without having to manually convert them?
- How do I loft the two curves together?
My next struggles will be to add a 4-point, symmetric spline to each arc to define the curve of the neck underneath. These will likely be just to establish the surface and be manually adjusted after creation.
Once I'm able to tackle basic neck construction I hope to incorporate the ability define the scale length of the guitar and then the number of frets.
I hope this made sense, if not I'll do my best to further explain my intentions!
Thank you!
- Brad