How to save all individual sub-assemblies and their parts from an assembly in STEP?

How to save all individual sub-assemblies and their parts from an assembly in STEP?

saikrishnaVKARF
Participant Participant
722 Views
7 Replies
Message 1 of 8

How to save all individual sub-assemblies and their parts from an assembly in STEP?

saikrishnaVKARF
Participant
Participant

After uploading the assembly step file in fusion 360 

I am not able to save all the  sub-assembly parts individually

0 Likes
723 Views
7 Replies
Replies (7)
Message 2 of 8

BrianEkins
Mentor
Mentor

Are you trying to do this interactively in the product or are you trying to write a program to do this?  And, what exactly is it you are trying to save? Each of the subassemblies within the main assembly because that would include the parts? Or are you wanting to save each part?

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 8

saikrishnaVKARF
Participant
Participant
I like to save each of the subassemblies separately
what exactly is, to save as files in folders like nested bom
0 Likes
Message 4 of 8

BrianEkins
Mentor
Mentor

It's still not clear to me.  If you have an assembly like this, what STEP files would you expect?

Structure.png

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 8

saikrishnaVKARF
Participant
Participant

how to save that subassembly components

sub 1

sub 2

sub 3

0 Likes
Message 6 of 8

BrianEkins
Mentor
Mentor

I didn't do a lot of testing, but I think this will do what you want.

 

def exportSTEP():
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui: adsk.core.UserInterface = app.userInterface

        design: adsk.fusion.Design = app.activeProduct
        root = design.rootComponent

        processedComponents = []
        occ: adsk.fusion.Occurrence
        for occ in root.occurrences:
            comp = occ.component

            # Check to see if this component is an assembly.
            if comp.occurrences.count > 0:
                found = False
                checkComp: adsk.fusion.Component
                for checkComp in processedComponents:
                    if comp == checkComp:
                        found = True
                        break

                if not found:
                    # Export this occurrence.
                    filename = 'C:/Temp/' + comp.name + '.step'
                    stepExport = design.exportManager.createSTEPExportOptions(filename, comp)
                    design.exportManager.execute(stepExport)

                    processedComponents.append(comp)
    except:
        ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 7 of 8

saikrishnaVKARF
Participant
Participant

Hi Brain!

while uploading a step file of top assembly which contains four subassemblies 

how can i able to save the four subassemblies individually 

can  u help me in this

0 Likes
Message 8 of 8

BrianEkins
Mentor
Mentor

What exactly is it you're trying to accomplish? It's still unclear to me what you need because if you only save subassemblies it will be likely you'll miss some parts. There are also cases where some subassemblies will end up being saved more than once because they might exist in other subassemblies.

 

You can see from the code above, that any component can be saved as a STEP file. It doesn't matter if that component represents the entire assembly, any subassembly, or any part. It's just a matter of determining which components you want to export and that's what is unclear to me.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes