Fusion 360 Python Script - Get Top Level Folder Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
I have created a project (folder), in Fusion 360, called "Purchased Parts".
Inside this "Purchased Parts" project (folder) I have created several sub-projects (folders) called "Bearings", "Fasteners", "Gearboxes" etc.
For testing purposes, I have inserted a part from the project (folder) called "Bearings" into a Fusion 360 assembly.
When I run the following code, I get the project (folder) name called "Bearings" displayed in a message box, however, I need to get the top level folder "Purchased Parts".
Does anybody know how I can change the following code so that I get the top level project?
Here is my code.
def traverseAssembly(occurrences, currentLevel):
app = adsk.core.Application.get()
ui = app.userInterface
for i in range(0, occurrences.count):
occ: adsk.fusion.Occurrence = occurrences.item(i)
doc: adsk.core.Document = occ.component.parentDesign.parentDocument
if doc.dataFile:
FolderName = doc.dataFile.parentFolder.name
ui.messageBox(FolderName, 'Fusion 360', 0, 3)
return FolderName
Therefore, the folder name should be "Purchased Parts" rather than "Bearings".
The line, coloured Red, needs changing.
Many thanks in advance!
Kindest regards
Darren