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: 

Return Path of folder

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
osamaolabi
314 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.

 

 

#Author-Osama
#Description-For Electrical DXFs imports

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


def run(context):
    ui = None
    try:
        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
        print(folderdlg.initialDirectory)
        

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

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

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 
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)
4 REPLIES 4
Message 2 of 5
kandennti
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.

1.png
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?

https://forums.autodesk.com/t5/eagle-forum/bd-p/3500 

Message 3 of 5
osamaolabi
in reply to: kandennti

Hello, 

 

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
BrianEkins
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.

 

print(folderdlg.folder)

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 5
osamaolabi
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  

Technology Administrators


Autodesk Design & Make Report