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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Return Path of folder

Message 1 of 5
231 Views, 4 Replies

Return Path of folder

Hello everyone,


I am trying to create a automated DXF Importer using PLB in the PCB design. 

Since I just started, I am having trouble returning the path of the chosen folder.

I tried using initialDirectory but that didn't work.



#Description-For Electrical DXFs imports

import adsk.core, adsk.fusion,, traceback
import os

def run(context):
    ui = None
        app = adsk.core.Application.get()
        ui  = app.userInterface
        #path = askdirectory(title='Select Folder') # shows dialog box and return the path

        # Creating a Folder Locater
        folderdlg = ui.createFolderDialog()
        folderdlg.title = 'Please select a folder to import DXFs:'
        res = folderdlg.showDialog()

        #Here is my try to print the path

         if res == adsk.core.DialogResults.DialogOK:
             folder = folderdlg.folder

             ui.messageBox('No folder is selected.')

        if ui:


The Script Proccess (if interested):
My next step, is to add all DXF's in the folder to a list. After that start the ULP for dxf import and browse in the path given previously. Select the Top file and compare it to the inital list, if the names match, it would select that file and remove it from the current list and add it to another list. Then it chooses the correct layer based on the file name and import it (file name is "1 Top.dxf" it would choose the "1 Top Layer" and import. after that it starts the ULP again and goes to the next file until the initial list is empty.

Labels (3)
Message 2 of 5
in reply to: osamaolabi

Hi @osamaolabi .


I have no knowledge of PCBs, so please forgive me if this is not appropriate for me to write about them.

I believe that the Fusion360 API does not support PCBs. Therefore, it seems unlikely that you will reach your goal.

I noticed that there is a "Run Script" in the PCB functions.

I don't know what it does or in what format, but it may be a better way to create the functionality you want.

Why don't you ask in the EAGLE Forum? 

Message 3 of 5
in reply to: kandennti



I was able to figure out how to get the PATH using another method. I will look into the run script option since I never looked into it. 


Also I didn't ask in Eagle since there is no API, and I am using API to control the Fusion360. Also I am using Fusion360 not Eagle.


Thank you for your help.

Message 4 of 5
in reply to: osamaolabi

Did you try the folder property?  Change your print statement to this and I think it will be what you want.




Brian Ekins
Inventor and Fusion 360 API Expert
Message 5 of 5
in reply to: BrianEkins

Hey @BrianEkins 


Thank you so much for your help, This indeed works.


I hope you have a wonderful day.



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