There are actually two ways to accomplish what you want. The first is what you suggested of uploading the file to A360 and then opening it from there. The second is to do the equivalent of the "New Design From File" command and then save it, which will then save it to A360. Below is some code that demonstrates uploading and then opening.
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Find the project by name.
proj = adsk.core.DataProject.cast(None)
for checkProj in app.data.dataProjects:
if checkProj.name == 'Junk':
proj = checkProj
break
# Get the root folder of the project.
folder = proj.rootFolder
# If you need to save it in another folder you can use this
# to get it by name.
folder = folder.dataFolders.itemByName('Samples')
# Upload the file. This will start the upload process.
future = folder.uploadFile('C:\Temp\Pistons.f3d')
# Monitor the upload, waiting for it to finish.
uploading = True
while uploading:
if future.uploadState == adsk.core.UploadStates.UploadFinished:
# The upload finished, so open the file.
app.documents.open(future.dataFile)
# Set the flag to break out of the loop.
uploading = False
elif future.uploadState == adsk.core.UploadStates.UploadFailed:
# The upload failed for some reason.
ui.messageBox('The upload failed.')
# Set the flag to break out of the loop.
uploading = False
# Turn control back to Fusion to allow it to process.
adsk.doEvents()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
And here's an example that imports and then saves. I think this is simpler.
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
# Create a new file by importing the existing file.
f3dImportOptions = app.importManager.createFusionArchiveImportOptions('C:\Temp\Pistons.f3d')
newDoc = app.importManager.importToNewDocument(f3dImportOptions)
# Find the project to save it to by name.
proj = adsk.core.DataProject.cast(None)
for checkProj in app.data.dataProjects:
if checkProj.name == 'Junk':
proj = checkProj
break
# Get the root folder of the project.
folder = proj.rootFolder
# If you need to save it in another folder you can use this
# to get it by name.
folder = folder.dataFolders.itemByName('Samples')
newDoc.saveAs('NewPiston', folder, '', '')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))