Hello @arjun_vermaWKZX3 ,
you can find more details about Fusion API here Fusion API (Application Programming Interface)
You can use the attached script to import multiple STL files into Fusion. However, since these files have irregular shapes, you may need to convert them back into solid bodies for easier editing, as working with mesh files can be quite challenging.
import os
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
try:
global ui
app = adsk.core.Application.get()
ui = app.userInterface
if (not ui.activeWorkspace.id == "FusionSolidEnvironment"):
modelWS = ui.workspaces.itemById("FusionSolidEnvironment")
modelWS.activate()
opFolder = GetFolderDialog('Fusion - Select folder location.',os.path.expanduser('~/Documents'))
doc = app.activeDocument
products = doc.products
design = adsk.fusion.Design.cast(products.itemByProductType("DesignProductType"))
rootComp = design.rootComponent
design.designType = adsk.fusion.DesignTypes.ParametricDesignType
for root, dirs, files in os.walk(opFolder):
for file in files:
fileName, ext = os.path.splitext(file)
if ext.lower() in '.stl':
tempStl = os.path.join(root, file)
baseFeatures = rootComp.features.baseFeatures.add()
baseFeatures.startEdit()
rootComp.meshBodies.add(tempStl,adsk.fusion.MeshUnits.MillimeterMeshUnit,baseFeatures)
baseFeatures.finishEdit()
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def GetFolderDialog(title = "" , initialDirectory= ""):
# Set styles of file dialog.
FolderDlg = ui.createFolderDialog()
if title != "" : FolderDlg.title = title
if initialDirectory != "" : FolderDlg.initialDirectory = initialDirectory
# Show File dialog
dlgResult = FolderDlg.showDialog()
if dlgResult == adsk.core.DialogResults.DialogOK:
FolderPath = FolderDlg.folder
if not os.path.isdir(os.path.dirname(FolderPath)):
ui.messageBox("Selectes folder is not exist")
return None
else:
return None
return FolderPath
Hope it helps.