- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.