Is there a way to open a Fusion 360 drawing file from a Python Script?

Is there a way to open a Fusion 360 drawing file from a Python Script?

spiritandsoledesigns
Explorer Explorer
772 Views
1 Reply
Message 1 of 2

Is there a way to open a Fusion 360 drawing file from a Python Script?

spiritandsoledesigns
Explorer
Explorer

I have a need to automate some tasks I do in FUSION360 in that I would like to execute a msdos batch file that may have 30-50 drawing file names in my Fusion360 projects folder, and have it call a python script which will open the fusion360 drawing, change a couple of the user parameter values and then export the drawing as stl to a network folder.

 

I found script that has example of how to change the user parameters and export as stl however I can't figure out how to get a python script to open fusion360 with a name of drawing file.   

 

Is there anyway to do this with the Fusion360 API?   Anyone know of any examples in Python?

 

Randy   

0 Likes
773 Views
1 Reply
Reply (1)
Message 2 of 2

jsormaz
Advocate
Advocate

 

 

app = adsk.core.Application.get()
ui  = app.userInterface

theData = app.data

dataProjectIndex = 0
i = 0
while i < theData.dataProjects.count:
  if (theData.dataProjects.item(i).name == 'PROJECT NAME'):
    j = 0
    while j < theData.dataProjects.item(i).rootFolder.dataFolders.count:
      if (theData.dataProjects.item(i).rootFolder.dataFolders.item(j).name == 'FOLDER NAME'):
      k = 0
      while k < theData.dataProjects.item(i).rootFolder.dataFolders.item(j).dataFiles.count:
            app.documents.open(theData.dataProjects.item(i).rootFolder.dataFolders.item(j).dataFiles.item(k),False)
      k += 1
    return
  j += 1
i += 1

 

 

This may get you started. This is part of an Add-In that I use to open all files within a certain folder in a certain project.

Instagram:
@sonsofsormaz