If you want to learn enough to write this program and others, you should start with an introductory course or book on Python. I haven't used these, but I've heard good things about Corey Schafer's videos on YouTube. I like "Python Crash Course" by Eric Matthes for a book.
Whatever you choose, you needn't be too concerned about the code editor they choose to use because when using Fusion, you'll be using Visual Studio Code. With Fusion, you don't have to worry about installing Python because it's installed as part of Fusion. However, following the tutorials to install an independent copy and learn to program Python independently of Fusion won't hurt. The main thing to focus on is the language itself.
Once you have a basic understanding of Python, you can learn how Fusion extends it to allow you to interact with it. There is a Programming Interface section in the Fusion help, where you'll want to focus on the User Manual section to get started.
If you're still unsure what to do, many great people on this forum are happy to share their experiences.
And here's a little bit of code to help you get started.
import adsk.core, adsk.fusion, traceback
def run(context):
try:
# Get the Fusion Application and UserInterface objects.
app = adsk.core.Application.get()
ui = app.userInterface
projectName = "Brian's First Project"
libraryFolderName = 'Library'
partName = 'Part1'
# Find the project that contains the library.
libProject: adsk.core.DataProject = None
for proj in app.data.dataProjects:
if proj.name == projectName:
libProject = proj
break
# Return an error if the porject was not found.
if not libProject:
ui.messageBox(f'The project "{projectName}" was not found.')
return
# Get the library folder.
libFolder = libProject.rootFolder.dataFolders.itemByName(libraryFolderName)
# Return an error is the library folder was not found.
if not libFolder:
ui.messageBox(f'The library folder "{libraryFolderName} was not found.')
return
# Get the file.
libFile: adsk.core.DataFile = None
for file in libFolder.dataFiles:
if file.name == partName:
libFile = file
break
# Return an error if the file was not found.
if not libFile:
ui.messageBox(f'The library file "{partName} was not found.')
return
# Get the Design object from the active document. This assumes the
# Design workspace is active.
des: adsk.fusion.Design = app.activeProduct
# Get the root component from the design.
root = des.rootComponent
# Insert the part into the current design. This uses an identity matrix
# which inserts the part at the origin, but you can define a matrix that
# will insert it at any location and orientation.
occ = root.occurrences.addByInsert(libFile, adsk.core.Matrix3D.create(), True)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com