<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Fusion 360 Python Script - Get Top Level Folder Name in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/fusion-360-python-script-get-top-level-folder-name/m-p/13326474#M222</link>
    <description>&lt;P&gt;Can anybody help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a project (folder), in Fusion 360, called "Purchased Parts".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inside this "Purchased Parts" project (folder) I have created several sub-projects (folders) called "Bearings", "Fasteners", "Gearboxes" etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For testing purposes, I have inserted a part from the project (folder) called "Bearings" into a Fusion 360 assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the following code, I get the project (folder) name called "&lt;STRONG&gt;Bearings&lt;/STRONG&gt;" displayed in a message box, however, I need to get the top level folder "Purchased Parts".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how I can change the following code so that I get the top level project?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def traverseAssembly(occurrences, currentLevel):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;app = adsk.core.Application.get()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ui = app.userInterface&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;for i in range(0, occurrences.count):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;occ: adsk.fusion.Occurrence = occurrences.item(i)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;doc: adsk.core.Document = occ.component.parentDesign.parentDocument&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if doc.dataFile:&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;FolderName = doc.dataFile.parentFolder.name&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ui.messageBox(FolderName, 'Fusion 360', 0, 3)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;return FolderName&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, the folder name should be "Purchased Parts" rather than "Bearings".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The line, coloured Red, needs changing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindest regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;</description>
    <pubDate>Tue, 18 Feb 2025 22:04:04 GMT</pubDate>
    <dc:creator>isocam</dc:creator>
    <dc:date>2025-02-18T22:04:04Z</dc:date>
    <item>
      <title>Fusion 360 Python Script - Get Top Level Folder Name</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/fusion-360-python-script-get-top-level-folder-name/m-p/13326474#M222</link>
      <description>&lt;P&gt;Can anybody help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created a project (folder), in Fusion 360, called "Purchased Parts".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Inside this "Purchased Parts" project (folder) I have created several sub-projects (folders) called "Bearings", "Fasteners", "Gearboxes" etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For testing purposes, I have inserted a part from the project (folder) called "Bearings" into a Fusion 360 assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the following code, I get the project (folder) name called "&lt;STRONG&gt;Bearings&lt;/STRONG&gt;" displayed in a message box, however, I need to get the top level folder "Purchased Parts".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anybody know how I can change the following code so that I get the top level project?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def traverseAssembly(occurrences, currentLevel):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;app = adsk.core.Application.get()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ui = app.userInterface&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;for i in range(0, occurrences.count):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;occ: adsk.fusion.Occurrence = occurrences.item(i)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;doc: adsk.core.Document = occ.component.parentDesign.parentDocument&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if doc.dataFile:&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;FolderName = doc.dataFile.parentFolder.name&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ui.messageBox(FolderName, 'Fusion 360', 0, 3)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;return FolderName&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, the folder name should be "Purchased Parts" rather than "Bearings".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The line, coloured Red, needs changing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindest regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 22:04:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/fusion-360-python-script-get-top-level-folder-name/m-p/13326474#M222</guid>
      <dc:creator>isocam</dc:creator>
      <dc:date>2025-02-18T22:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fusion 360 Python Script - Get Top Level Folder Name</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/fusion-360-python-script-get-top-level-folder-name/m-p/13326748#M223</link>
      <description>&lt;P&gt;I think it needs to be:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;FolderName = doc.dataFile.parentProject.name&lt;/LI-CODE&gt;&lt;P&gt;The problem is that you're interchangeably using the terms "Project" and "Folder", but they're two distinct and different things.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Feb 2025 01:10:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/fusion-360-python-script-get-top-level-folder-name/m-p/13326748#M223</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2025-02-19T01:10:17Z</dc:date>
    </item>
  </channel>
</rss>

