Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Python - Export BOM File With "Full" Folder Path

1 REPLY 1
SOLVED
Reply
Message 1 of 2
isocam
109 Views, 1 Reply

Python - Export BOM File With "Full" Folder Path

Can anybody help???

 

Please see the attached picture and Python script (I have changed the file name extension from "py" to "txt).

 

All I need is the script file updating so that it will output the folder path of a part that was inserted into an assembly.

 

For Example:

 

Say I have an assembly containing several parts. One of these parts has been inserted from the folder called "Purchased Parts" > "Bearings" (Please see the attached picture).

 

I need to add the folder path to the output, in the above case, this would be "Bearings".

 

Is the above possible?

 

Many thanks in advance!!!

 

Darren

1 REPLY 1
Message 2 of 2
BrianEkins
in reply to: isocam

Here's a modified version of your traverseAssembly function that gets the folder name and I believe should also get the quantity. I think there is still some tweaking to do to clean up the output.

 

def traverseAssembly(occurrences, currentLevel, inputString):
    for i in range(0, occurrences.count):
        occ: adsk.fusion.Occurrence = occurrences.item(i)
        PartNumber = re.split(' v\d+', occ.name)[0]
        PartDescription = occ.component.description

        doc: adsk.core.Document = occ.component.parentDesign.parentDocument
        if doc.dataFile:
            FolderName = doc.dataFile.parentFolder.name
        else:
            FolderName = 'Unsaved'

        PartQuantity = occ.sourceComponent.occurrencesByComponent(occ.component).count
        inputString += SpacePadRight(PartDescription, 77) + SpacePadRight(PartQuantity, 14) + SpacePadRight(FolderName, 41) + SpacePadRight(PartNumber, 53) + '\n'

        if occ.childOccurrences:
            inputString = traverseAssembly(occ.childOccurrences, currentLevel + 1, inputString)

    return inputString

tra 

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report