I wish to write a Macro that process a directory, is there a good way to pass a file system path to a FCmacro?
Thanks
SOLVED : Passing a files system path to a FCMacro
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: SOLVED : Passing a files system path to a FCMacro
Code: Select all
from PySide import QtGui
name=QtGui.QFileDialog.getOpenFileName()[0]
-
- Veteran
- Posts: 2764
- Joined: Mon Feb 27, 2012 5:31 pm
Re: SOLVED : Passing a files system path to a FCMacro
In the end went with
Code: Select all
import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *
path = FreeCAD.ConfigGet("UserAppData")
#getExistingDirectory(QWidget *parent = nullptr, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = ShowDirsOnly)
Directory = PySide.QtGui.QFileDialog.getExistingDirectory(None, "Select a directory",path)
print(f"Selected Directory {Directory}")