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.
Solved! Go to Solution.
Solved by BrianEkins. Go to Solution.
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?
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.
Did you try the folder property? Change your print statement to this and I think it will be what you want.
print(folderdlg.folder)
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.