How to export Step file of each part in assembly?

How to export Step file of each part in assembly?

ruban2
Participant Participant
240 Views
1 Reply
Message 1 of 2

How to export Step file of each part in assembly?

ruban2
Participant
Participant

Hello

I know method to export step file of assembly. https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-B801DDA8-9A0C-42AD-AC06-F8244CA08D65 

 

But my assembly include many parts.
so I'd like to export step file of each part.

But I don't know method.

 

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

kandennti
Mentor
Mentor

@ruban2 .

 

We don't have enough information to know exactly what you want.
(e.g. depth of the component, you want the output in the position it is positioned at the joint, etc.)

 

We have created these scripts in anticipation.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion
import pathlib
import re

EXPORT_FOLDER = pathlib.Path(r'C:\temp')

def run(context):
    ui = core.UserInterface.cast(None)
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface
        des: fusion.Design = app.activeProduct
        root: fusion.Component = des.rootComponent

        exportMgr: fusion.ExportManager = des.exportManager

        app.executeTextCommand(u'Transaction.Start export_step')
        set_all_lightbulb(False)

        # export root component
        root.isBodiesFolderLightBulbOn = True
        path = str(EXPORT_FOLDER / get_export_file_name(f'{root.name}') )
        stpOptions: fusion.STEPExportOptions = exportMgr.createSTEPExportOptions(
            path,
            root
        )
        exportMgr.execute(stpOptions)
        root.isBodiesFolderLightBulbOn = False

        # export occurrence
        for occ in root.occurrences:
            occ.isLightBulbOn = True

            path = str(EXPORT_FOLDER / get_export_file_name(f'{occ.name}') )
            stpOptions = exportMgr.createSTEPExportOptions(path, root)
            exportMgr.execute(stpOptions)

            occ.isLightBulbOn = False

        app.executeTextCommand(u'Transaction.Abort')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def get_export_file_name(fileName: str) -> str:
    return re.sub(r'[\\|/|:|?|.|"|<|>|\|]', '_', fileName)


def set_all_lightbulb(isLight: bool) -> None:
    app: core.Application = core.Application.get()
    des: fusion.Design = app.activeProduct
    root: fusion.Component = des.rootComponent

    root.isBodiesFolderLightBulbOn = isLight

    occ: fusion.Occurrence = None
    for occ in root.allOccurrences:
        occ.isLightBulbOn = isLight

 

If it is different from what you want, please attach as simple and specific f3d/f3z files as possible.